mattbierner / khepri

ECMAScript derived programming language
http://khepri-lang.com/
MIT License
67 stars 3 forks source link

Lambda Capture Limiter Member Access #98

Closed mattbierner closed 10 years ago

mattbierner commented 10 years ago

Chaining expressions with Fantasy lands API currently requires parens on lambdas:

a
    .chain(\x -> ...)
    .chain(\y -> ...);

Specifically for the case of member access, or perhaps as a more general purpose solution, a way to limit the lambda capture so we could write

a
    .chain \ x -> ...
    .chain \ y -> ...;

would be preferable.

Perhaps something like:

a
    ..chain \ x -> ...
    ..chain \ y -> ...;

Where .. has the lowest precedence.

mattbierner commented 10 years ago

.. does not solve the case:

\x -> ...
   \> g

where the programmer intended to compose the lambda with g instead of creating a lambda whose body is composed with g.

Current consideration is to use a special symbol that can stop lets and lambda from capturing (Something like Haskell's $ but Haskell's $ logic cannot be easily applied to ECMAScript).

Possibilities: §

One would write:

M.of(...)
     .chain \ x -> ... §
     .chain \ y -> ... §