If we ever hope to include "elvis". obj?:[expr]
would be roughly equivalent to: obj != null ? obj : [expr] rather than what you are suggesting here: obj != null ? obj[expr] : undefined; On Sun, Feb 7, 2016 at 4:16 PM, Bergi <[email protected]> wrote: > Claude Pache wrote: > >> >> .? >>> (?) >>> [?] >>> >> >> Yes, that syntax is possible. Whether it is preferable is a question of >> taste. Personally, I don’t like it: >> >> * I slightly prefer `?.` over `.?` for the following reason: The `?.` >> token may be conceptually separated in two, first the question mark which >> checks whether the expression at its left evaluates to null/undefined (and >> orders to stop processing if it is the case); then the dot which proceeds >> with property lookup. >> > > Totally agreed. > > * I find that the question mark inside the brackets is out of place, as it >> isn’t part of the arguments (for function call) or of the expression >> defining the key (for property access). >> > > I agree here as well, it does feel out of place, and `?[…]`/`?(…)` would > feel a lot more natural. Given that those are not feasible for parsing > however, I would still prefer them > > obj[?expr] > func(? …args) > new C(? …args) > > over the proposed alternative > > obj?.[expr] > func?.(…args) > new C?.(…args) > > where the placement of the dot is just horrifying my eyes. > Maybe we could at least use some other character instead of the dot? > > obj?:[expr] > func?:(…args) > new C?:(…args) > > might bear too much resemblance to the ternary, but imo the colon fits > better than the dot here. > > Regards, > Bergi > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

