Proposal: paren-free function calls and definitions

Claus Reinke claus.reinke at talk21.com
Sun Jun 19 15:17:37 PDT 2011


Dear all,

following the recent suggestion here that github might be a
more suitable forum for kick-starting proposals than this list,
I've put together a proposal draft on simple paren-free function
calls and definitions:

https://github.com/clausreinke/jstr/tree/master/es-discuss

You can find there the proposal text, with motivation, grammar 
changes, semantics (entirely via desugaring to existing syntax), 
and related issues, as well as a prototype implementation, using 
jstr's nascent grammar-based ES-to-ES rewriting:

    tailnests.txt: proposal text

    tailnests-examples.js: some small illustrative examples

    tailnests.html: if you clone the jstr repo, this is a simplistic
        interface to a prototype implementation (one textarea
        for source input, one textarea for desugared output)

    ../es5.js: near ES5 grammar, with proposed extensions
        (look for rules guardes with LANGUAGE.tailnests)

The proposal concerns the old topic of removing some 
syntactic obstacles from Javascript's functional core. 

Over the years, this list has seen numerous more or less 
ambitious proposals and discussions on this topic, and every 
single one of them seems to have got stuck at some point. 

Therefore, this proposal deliberately focuses on the less 
controversial aspects of the problem. The plan is to to work 
out a minimal solution that helps, for instance with nested 
callback chains, and with monadic programming, without 
raising serious concerns about semantic changes. In other
words, the goal is to make progress, however minimal.

The base proposal focuses on definitions of simple expression-
returning functions and calls with primitive or function
expression arguments. Paren-free left-associative function 
application is done as a simple generalization of existing
grammar, while paren-free right-associative function 
application needs an infix operator. All grammar changes
are localized, new rules are controlled by small lookahead,
and ASI changes are flagged as parser warnings.

If you find the base proposal suitable, the additional notes
make two suggestions for removing the remaining syntactic
issues in future language versions. Separating out the 
syntactic issues and leaving the controversial semantic 
issues for other proposals, should help to make progress 
on the former - if it also gets the latter unstuck, all the better.

Looking forward to your feedback,
Claus

PS. I assume that proposal discussion is still going to take
    place here on this list.

 


More information about the es-discuss mailing list