-
Notifications
You must be signed in to change notification settings - Fork 29
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
Considering alternative syntax for using value
#65
Comments
Why not put This has the benefit that one can now disambiguate between taking ownership of values obtained from destructuring and the destructured object itself (what everyone in #13 couldn’t get to agree on): e.g. |
For now we're not allowing binding patterns with |
that might be an improvement tho - it's much more granular and explicit. (ftr, it's already generally considered a bad style to declare more than one variable on the same keyword - ie, only ever one const per const, etc - so i'm not sure how often people will do that anyways) |
Its also important that the syntactic |
"front and center" could be read to mean "near the identifier" over "near the const", but fair that it was already discussed. |
Can you spot the problem? |
That would be a parse error. The syntax in #56 specifies that the "bindingless" |
You could do |
Also, as @ljharb pointed out, combining is generally a poor style decision, so you will more often see this: using const x = f();
using const (g(a, b()));
using const y = ...; However, this doesn't necessarily mean we should forbid the convenience of chaining multiple declarations: using const x = f(),
(g(a, b())),
y = ...; |
I'm not opposed to alternatives to |
https://tc39.es/proposal-explicit-resource-management/pr/56/ Specifically this section: https://tc39.es/proposal-explicit-resource-management/pr/56/#sec-let-and-const-declarations |
For the upcoming meeting I am planning to use |
Why don't we replace This would be more compact and be more clear given that This would also fit well with destructuration using x = ...
using a = ..., b = ...
using { a, b } = object
using [a, b] = array |
Rather than introduce a second contextual keyword (i.e.,
value
), I'm considering changing the syntax for the version that does not introduce a binding tousing const (expression);
using const void = expression;
.This has several benefits:
value
).using
could be performed inline in the same statement:using const x = f(), (g()), y = h();
using const
is already a subtly different grammar thanconst
, asusing const
does not permit destructuring, so having a()
syntax unique to that declaration shouldn't conflict with existing syntax. The treatment of,
in ausing const
declaration is similar to that of a normalconst
(orlet
/var
), so there is no parser ambiguity with respect to,
expressions.Since
void
is not a legal identifier, there should be no syntactic ambiguity. In addition, the termvoid
generally refers to something that we want to ignore, or that doesn't exist, so usingvoid
in place of a BindingIdentifier to indicate an unwanted binding isn't too far-fetched. In addition, it allow a bindingless declaration to look syntactically similar to a regular declaration:The text was updated successfully, but these errors were encountered: