On Apr 14, 2011, at 8:59 PM, P T Withington wrote: > On 2011-04-13, at 15:23, Brendan Eich wrote: > >>> in my view, the operator is not "?." (i.e. "a question followed by a dot"), >>> but still just ?. The following dot is already about property accessor: >>> >>> foo.bar?.baz >>> >>> again, bar? is separated, and only after that it's accessed to `baz` via >>> casual dot notation. >> >> ?. is doable as a new operator > > And ?( as an operator, too?
That would seem to want a bottom up parser. Consider (a?(b instanceof c):d) vs. (a?(b instanceof c)) A top-down parser could simulate by parsing ahead assuming ?:, and in the second case on finding no : where expected, revise the AST for the prefix that was already parsed. This looks nasty, and it needs more rigorous validation. It is also future-hostile to using : in new ways that might start an expression -- probably not an issue but I'll throw it out. > This is the way AS2 worked. If at any point an undefined value was hit > (whether property access or call), the evaluation stopped and undefined was > returned. The experience of OpenLaszlo was that this led to many myserious > bugs. We ended up making our compiler insert annotations in debug mode to > detect and warn when an expression failed due to an undefined value. This is compelling testimony. I didn't know that about AS2. > That experience makes me believe that the current behavior in ES is a better > default; but having a shorthand for "stop now if this is undefined", seems > like it would be a nice addition. Agree on first part. "[N]ice addition" depends on making the syntax usable and easy to parse. /be _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

