Civet
Civet copied to clipboard
`var` declaration shorthand
There's been requests for a shorthand var to go alongside let and const.
Here are some ideas:
..=
,=
;=
Any others we should consider?
var is closer to let than const so I'd suggest nixing ;=.
,= seems superior to ..= because it's shorter...
I'm not sure that any of them communicate "function scope". Ah, maybe ..= does because it could mean "some levels up". Maybe the comma in ,= is pointing to the function — though that should probably be up not down. In some ways ^= or `= or '= would make sense, pointing to where the declaration hoists, but these already have meaning. \= seems too weird.
I think I'm currently leaning ,=. Anyone else have thoughts?
My preference is ..= since it is the same as .= for let but with expanded scope. And typing two of the same character twice isn't much slower than typing it once.
I'd prefer not to use ;= since it has the upper dot which I like to think of as a "read only" bit. We could also theoretically add a .:= for a var scoped const (only enforced by compiler warning, still transpiles to var)
@edemaine @STRd6 Why not just =? Whereby if not previously declared, it defaults to var, like CoffeeScript…
@danielbayley We already have that as an option, but you have to enable it, via "civet autoVar" or "civet coffeeCompat". See the documentation.
@danielbayley We already have that as an option, but you have to enable it, via
"civet autoVar"or"civet coffeeCompat". See the documentation.
A yeah I had seen that thanks, just wondered why it wasn’t the default behaviour… Then again I thought maybe let should be the default… which I didn’t realise was also an existing option.
Speaking of prologue directives, I would much prefer to put these settings in the config instead… Is that in the pipeline? @edemaine
Speaking of prologue directives, I would much prefer to put these settings in the config instead…
@danielbayley Better to take that discussion elsewhere (new discussion or Discord), but there is already limited (but undocumented) config support.