Novel operator syntax

Brendan Eich brendan at mozilla.com
Tue Oct 29 15:03:52 PDT 2013


Axel Rauschmayer wrote:
> I would love to have a way to write function calls infix. That may 
> cover your use case as well. That is (strawman syntax):
>
>     arg1 #func arg2
>
> would be syntactic sugar for
>
>    func(arg1, arg2)
>
> Advantages: more versatile, less grawlixy.

# is pure grawlix. It's also one of the few ASCII punctuators left, so 
wanted otherwise.

> Problem: would make much more sense with multiple dispatch (dynamic 
> dispatch over the arguments), but that doesn’t seem to be in the cards 
> for JavaScript.

The operators stuff I've been developing uses a variant of multimethod 
dispatch.

Operators cannot be usable if spelled #add, so we must support all the 
built-in ones I've talked about (see 
http://www.slideshare.net/BrendanEich/js-resp). Whether we need 
element-wise operators is really what this thread is about (I think, 
based on Tristan's spinout). Arbitrary infix named operators IMHO want 
another thread, and also later. Design means leaving things out (N. Wirth).

/be


More information about the es-discuss mailing list