Refutable pattern

Brendan Eich brendan at mozilla.com
Fri Feb 8 16:23:55 PST 2013


You're right (and take that, olliej :-P).

The other synergy with CoffeeScript is the existential operator in the 
expression grammar (not just patterns):

if (foo?) ...

And the o?.p and o?m() variants, but these won't make it as-is due to 
lack of compositionality for ?. and no way to add ?( to ECMA-262 given 
?: expressions.

/be

Russell Leggett wrote:
>
>
>         I think prefix ? is easier from a reading point of view, but
>         I'm not really married to either.
>
>
>     Agreed, and I posted mainly to try to get to consensus. Prefix-?
>     looks like it is in the lead.
>
>
> I think for the case of a long pattern with the ? outside the {}s, a 
> prefix ? is easier to read. However, I think the reason why 
> coffeescript and typescript have gone with a suffix is because it is 
> more common and natural with the way ? is already used. To me it 
> *screams* optional from regular expression languages, but then is also 
> the obvious placement for english and many other written languages for 
> the uninitiated.
>
> The regular expression notation is probably the most compelling reason 
> to me for suffix-?. It is widely used across different regular 
> expression implementations, including ecmascript's. The regular 
> expression roots have also made it used in other related ways. For 
> example, many different schema notations use it like DTDs
>
> <!ELEMENT ARTICLE (TITLE?, P*)>
>
> Or relax ng compact syntax
>
> element note { text }?
>
> The precedence is more than just coffeescript.
>
> - Russ
>
>
>
>     /be
>
>     _______________________________________________
>     es-discuss mailing list
>     es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>     https://mail.mozilla.org/listinfo/es-discuss
>
>


More information about the es-discuss mailing list