Refutable pattern

Russell Leggett russell.leggett at gmail.com
Thu Feb 7 06:21:30 PST 2013


>
>
>  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
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130207/c0a47bfa/attachment-0001.html>


More information about the es-discuss mailing list