

[Language design] Getting rid of keywords for fun and profit - krajzeg
http://wasyl.eu/programming/2014/03/08/getting-rid-of-keywords-part-1.html

======
gus_massa
The rules look like a mix of many special cases. Can this be implemented as
currying?
[http://en.wikipedia.org/wiki/Currying](http://en.wikipedia.org/wiki/Currying)

~~~
krajzeg
I assume you mean the rules for parsing code blocks (anonymous functions).
Maybe I muddled it in the post, but the actual rules are very simple:

1\. <call(arg1,arg2,...)> {block} => <call(arg1,arg2,...,{block})> 2\.
anything {block} => anything({block})

So the actual rule is that a block standing to the right of something either
creates a new function call, or gets added to the existing one. The same
applies to argument lists.

This means that you can do: x(1,2) {a} (3) {b}, and what happens is very
regular - a function call: x(1,2,{a},3,{b}).

I know of currying, but its not used for simple calls. A solution that shares
some concepts with currying was used for handling if..else,
try..catch..finally and other multi-part statements.

~~~
gus_massa
Rule #1 can be included in #2 with currying.

I use [ ] as "invisible" separators, to make clear what is evaluated first,
and #%If as a core version of If, perhaps programmed in another language.

In the expression

    
    
      If (x<3) {console.newline;}
     

First, the If part is curryied

    
    
      [If (x<3)] => [function(x) {#%If (x<3, x)}]
    

And then we have

    
    
      [function(x) {#%If (x<3, x)}] {console.newline;}
    

Applying rule #2

    
    
      [function(x) {#%If (x<3, x)}] ({console.newline;})
    

That is equivalent to

    
    
      #%If (x<3, {console.newline;})
    

I'm not sure if this approach work and handle all the corner cases.

