aardappel / lobster

The Lobster Programming Language

Home Page:http://strlen.com/lobster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding let keyword to higher order function calls

JakeCoxon opened this issue · comments

Sometimes when reading the code as someone new to the language it's not too obvious in the following lines of code, which are values passed to the function and which are variable bindings of a lambda

foo(a) b:
  ...
foo() a:
  ...
foo a:
  ...

I have a pretty wild idea, what if you add a required keyword let before the variable binding, and now it is a bit clearer what's being bound to a new identifier. The above becomes

foo(a) let b:
   ...
foo() let a:
  ...
foo a:  // stays the same
   ...

Obvious downside is you introduce an extra keyword you didn't need before, but now you can remove the parentheses: foo a let b:

Examples:

for bullets let b:  // kind of like python's `for b in bullets` but reversed
  ...
take n let yield:
  ...
in_box let v, tile:
  ...

I think it also helps #56 as well because for (bullets) let b: and for(bullets) let b: is equivalent

Just an idea I had, feel free to close if it's not applicable

I agree it would be clearer.. but don't think I like the look of this more verbose version. It would also be a very breaking change (affecting all control structures and functions)

@J0eCool @jcorbin will have opinions.

Concerning the look-and-feel, would ruby-style look better:

for bullets |b|:
  ...
take n |yield|:
  ...
in_box |v, tile|:
  ...

That could work equally well, yes. But we decided to go with a more Python style, and certainly making such big changes to the syntax at this stage would need very strong reasons.