Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percent less #1735

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Percent less #1735

wants to merge 5 commits into from

Conversation

let-def
Copy link
Contributor

@let-def let-def commented Jan 7, 2018

Allow extension sugar without having to put %:

let async f = ...
/* as well as */
switch async / try async / for async / if async / ...

The sugar applies for any lowercase identifier that is not a keyword.

The let f() = ... / let f() { ... } syntax had to be removed (functions are now always bound like any other expressions, let f = () => ...).

@hcarty
Copy link
Contributor

hcarty commented Jan 7, 2018

OCaml supports ;%extend - is there a way to support a Reason equivalent with this syntax? It would be useful for operations used purely for side effects like printing/logging.

@jordwalke
Copy link
Member

It's a very nice surprise that Reason's syntax enabled us to omit the % without any ambiguities. This looks really approachable.

A couple of thoughts: We would probably want to start with make omitting the % opt-in, just in case we for some reason need to use a different solution in the next release. In that way people could try it out that it's subject to change.
We also might want to only add a few whitelisted ppx names to be printed with the % omitted because it might look confusing for other ppx names.

For some reason it's failing on Mac OS only with " Error: 8 states have shift/reduce conflicts."

@let-def
Copy link
Contributor Author

let-def commented Jan 8, 2018

The conflicts are due to the patch forcing parentheses around switch/try scrutinee being reverted.

@ELLIOTTCABLE
Copy link

Wow. This would really be the killer feature of the Reason syntax, IMO.

Well, assuming the BuckleScript team relaxes its position on AST modification. 🤣

@jaredly
Copy link
Contributor

jaredly commented Aug 2, 2018

ummm I have strong reservations about elevating ppx extension points to this level of "prominence" in the syntax. I believe it should be fairly "loud" when a syntax transform is happening.
@chenglou and I have talked about an alternate proposal that would allow monads to be handled gracefully without relying on ppx's (basically through first-class CPS support).
it would involve introducing a let!foo x = y; ...etc form that would be translated to foo(y, x => ...etc)
This allows us to handle async, optionals, results, etc, while also allowing you to cmd-click into foo to see what's happening. It feels much less magic than ppxs, which I like a lot.

@hcarty
Copy link
Contributor

hcarty commented Aug 2, 2018

@jaredly There are a few relevant active PRs upstream which may be of interest and worth chiming in on to make sure the Reason community's needs are taken into account.

Monadic let operators - ocaml/ocaml#1947

match operators - ocaml/ocaml#1955

@jaredly
Copy link
Contributor

jaredly commented Aug 2, 2018

@hcarty wow, that's a very cool proposal!
it would be cool to have something like that for reason, especially if we found a way of having readable text (let!foo) as opposed to relying on symbols exclusively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants