tj / luna

luna programming language - a small, elegant VM implemented in C
2.45k stars 147 forks source link

new lambda syntax #10

Closed tj closed 12 years ago

tj commented 12 years ago

currently:

users map(:user | user pet) select(:pet | pet age > 10)

is equivalent to the following, but allows for implicit returns

user
  map: user
    ret user pet
  select: pet
    ret pet age > 10

or equivalent to the following javascript:

users.map(function(user){
  return user.pet
}).select(function(pet){
  return pet.age > 10
})

I dont like the current syntax, but I dont want lookahead like dart's (foo, bar) { } syntax or (foo, bar) ->, it makes you scan further ahead than you should have to in order to disambiguate. We could do some special-casing but I dont want to get too deep into that either.

Alternatively or as a compliment it would be nice to quote and provide something like:

users map(.pet) select(.age > 10)