-
Notifications
You must be signed in to change notification settings - Fork 429
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
v2 syntax still used in lazy
pattern matching
#2575
Comments
Counter argument: perhaps defining a Rather than |
Parentheses were added for constructing lazy values in #2376. However I guess we missed adding them to the |
I didn't know about it either until the blog post 😂 I agree we should be consistent, but after the discord discussion I think I'm leaning towards reverting to never have brackets rather than adding them to the pattern matching. |
We should consider overall syntax consistency. Reason syntax makes any kind of value construction look like function application e.g. |
I think special syntax for special things makes sense, for example in JS For constructing values, sure, function syntax makes sense. But |
Reason has already added let-operators. It's part of the language now. [Edit: I think I misunderstood you, do you mean if Reason adds
|
Yes, I meant adding
|
But the whole point of promises is to turn asynchronous computations into first-class values that can be passed around. Lazy values are values in exactly the same sense. Anyway I think we are really in #bikeshedding territory now. |
We are definitely bikeshedding, but if I do nothing brackets will be added. I'm growing more convinced reverting brackets is the better answer.
Yes, they are both special values that suspend computation from the line of code they're defined in, which is why having special syntax for both seems fine to me. |
|
Promises suspend computation at the line of code they are defined on, yes they run after the current stack frame but that's an implementation detail. I don't actually use |
We've spent quite a bit of time talking about a hypothetical async/await syntax for Reason, something I'm fairly sure will not happen now that let-operators are officially part of the language. But just to be clear. There's no special syntax in JS for creating promises, unless you count marking a function as As I mentioned before, we already have a syntax for constructing values in Reason, and it looks like function application. Yes, constructing lazy values is semantically different, but it's not different enough that it warrants some special rule. Consider that in OCaml syntax, it looks like normal function application too: |
I have come across a case where
refmt
not only supports v2 syntax but outputs it 😮While reading the BuckleScript blog post about the new lazy encoding, I noticed a cool way to unpack
lazy
values without callingLazy.force
:let (lazy(value)) = myLazyValue;
Or rather, that's what I expected the syntax to be. Turns out the syntax in the blog post is not only valid reason, it's the syntax
refmt
converts the above to. No brackets.let lazy value = myLazyValue;
proof this syntax works:
https://reasonml.github.io/en/try?rrjsx=true&reason=DYUwLgBAtgngMgQwF4wGoOAVxBAvBYZGACgCIALAS1IEoBuAKAYHoAqCAd3IUgEkIQADwAOIAMaRWzBqEjFCKYgDcM2GjTzR4RdFhCMAUgGcAdMAD2Ac2WqQ9Jm07dIAJxAAzKJHOYww30YQUjLgBEQQKnqasIgoutiGphbWkWqMQA
I'm using
The text was updated successfully, but these errors were encountered: