lambdascript icon indicating copy to clipboard operation
lambdascript copied to clipboard

shorthand lambda with a backslash \ ?

Open RadZaeem opened this issue 8 years ago • 2 comments

writing lambda everytime can be tedious, so can it be just shorthanded with a "" symbol, like Elm did with anonymous function e.g.

\x: x+1

RadZaeem avatar Feb 04 '17 08:02 RadZaeem

Hi RadZaeem, thank you for your comment. The current parser is actually the true Python parser, since the syntax is compatible with Python synax (as long as you enclose a block in braces {...} which makes the interpreter think a Lambdascript block is a Python dictionary). This allows to have a very compact and reliable parser and the code of the module focuses rather on internal mechanisms (mostly for being objects together).

That being said, I could perhaps write a second function for parsing the code (and allow the user to call either one or the other); I have to think about it in order to produce something clean enough. I agree it would be nice to have such a syntax.

baruchel avatar Feb 04 '17 17:02 baruchel

I think a clearly way to do this would be (x) -> x + 1.

ghost avatar Mar 08 '17 14:03 ghost