Brendan Eich wrote:
Allen Wirfs-Brock wrote:
yes, that's what I was proposing. I think calls need to be part of the
overall discussion for this feature area.
Jeremy is kindly grepping more codebases, but just from CoffeeScript
(self-hosted) source itself, ?. is 42, ?[ is 7, and ?( is 3 -- so
12:2:1. Supports deferring ?( for now given syntax issue, but the
counter-argument is that we might solve syntax holistically a different
way. One idea:
foo.?bar instead of foo?.bar
which enables
foo(? args )
instead of
foo?( args )
and implies
foo[? index ]
This is infelicitous compared to putting ? first because it separates
the ? from the maybe-nully left operand too much, and looks ugly (to
Spanish readers it looks even more wrong).
Let's allow foo.? to denote "soft foo", so you get:
foo.?.bar // foo == null ? undefined : foo.bar
foo.?(bar) // foo == null ? undefined : foo(bar)
foo.?[bar] // foo == null ? undefined : foo[bar]
but maybe also more esoteric uses, like:
for (let key in foo.?) // for (let key in (foo == null ? {} : foo))
foo.? // foo == null ? undefined : foo // sort-of clearing
foo.? = bar // foo == null ? undefined : (foo = bar)
// this semantics is logical, just don't know
// what would be the use case...
foo.?.baz = bar // foo == null ? undefined : (foo.baz = bar)
// this is usable
... foo.? ...
Herby
The other idea mooted:
foo?:( args )
runs into the X ?: Y problem -- that should mean X ? X : Y per GNU C and
intuition, but the : in the middle of ?:( doesn't mean any such thing.
My super-flammable straw syntax of foo?.(args) has a similarly inapt dot
in the middle.
Suggestions welcome. If we must get maybe-call in or at least
future-proof the syntax for it a bit, now is the time.
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss