Proposal: Selector/Select Expression
naveen.chwl at gmail.com
Sun Jun 23 06:28:45 UTC 2019
I am guessing this doesn't allow any operations other than the "dot path"
to a function or property... Are you comfortable with that? If so, why? I
have found myself doing things like a=>a.x/2 . I couldn't do that in
proposed way, could I? Have you found, in your experience, that a "dot path
only" return value is common enough to save you a lot of effort, and
justify not being easily extendable to accept other operations, other than
having to switch to the arrow syntax again, which could be cumbersome?
If you are comfortable with all these things, then I have no problem with
the proposal really. I wouldn't lose anything. For me it would be like the
"if" clause not requiring curly braces if there's only 1 statement - I
simply always use curly braces - and might simply always use arrow
functions - for the purposes of extensibility - but I'm not sure.
Thoughts? Have I missed something?
On Sun, 23 Jun 2019 at 07:05, Bob Myers <rtm at gol.com> wrote:
> > In any event, re-read the proposal. Am certainly not opposed to the
> proposal to substitute ```|>```, and or ```.``` at ```const getEmail =
> .contacts.email;``` as the first character after ```=``` for `=>`,
> meaning the initial ```.``` following ```=``` is interpreted as a function
> call, equivalent to ```=>```? Can you include comments next to the examples
> This proposal has nothing to do with ```|>```. It is a variation of dot
> notation, the classic notation ```o.p``` that has been a feature of JS
> since its inception, to treat ```.p``` as a function (not a function call)
> taking one argument and returning the value of the property ```p``` in that
> object. To put it a different way, if the object normally preceding the dot
> is omitted, the construct is treated as a property picking function. It is
> not a matter of the dot necessarily having to follow an equal sign, or
> having some special meaning only that context; ```.p``` not preceded by an
> object is a function regardless of the context. To my knowledge, there is
> no ambiguity in this notation. In other words, there is no case in which a
> dot not following an expression and followed by an identifier is anything
> other than a syntax error at present--please correct me if I'm wrong.
> Although not mentioned in the brief propsoal, there is no logical reason
> that the analogous property access syntax ```.[prop]``` could not be
> allowed. There also does not seem to any reason to prohibit the use of this
> construct for arrays, so ```.``` could be the "head" function people
> have been talking about for years.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss