top-level bindings of let/const/var
Closed this issue · 7 comments
Is there a reason to allow top-level void bindings in let/const/var declarations? I don't ever want to see let void = procedure();
. I would prefer these cases were not permitted.
The only real motivation is consistency with using
. As I mentioned during plenary, there's a very minor benefit if you have code like const a = f(), b = (g(), h())
, but that's not a very strong motivation. I'm fine with excluding these from the proposal.
I'm discussing the wrong proposal here, but if consistency with using
is a concern, why is using void = Acquire()
needed instead of just using Acquire()
? The latter seems more straightforward to me. The former uses binding syntax only to explicitly say that it is not creating a binding.
using Acquire()
seems fine at first glance, but using (Acquire())
or using (foo || bar).Acquire()
, or any other expression that starts with parentheses is already legal JavaScript. Disambiguating it for just this case would be a huge footgun for users.
Also, per #3 the current spec text disallows top-level void
bindings in let
/const
/var
.
using Acquire()
seems fine at first glance, butusing (Acquire())
orusing (foo || bar).Acquire()
, or any other expression that starts with parentheses is already legal JavaScript. Disambiguating it for just this case would be a huge footgun for users.
Isn't using [a] = Acquire()
already valid though?
using Acquire()
seems fine at first glance, butusing (Acquire())
orusing (foo || bar).Acquire()
, or any other expression that starts with parentheses is already legal JavaScript. Disambiguating it for just this case would be a huge footgun for users.Isn't
using [a] = Acquire()
already valid though?
Yes, but binding patterns are illegal in using
. The issue with using expr
is that it is far more ambiguous as to what is allowed. ()
is a PrimaryExpression and is allowed pretty much anywhere you might write an expression. Drawing an arbitrary line around parts of PrimaryExpression would be a huge footgun.
Ah, I didn't see that you had added the Pattern
flag to BindingList
.