tj / luna

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

Anonymous functions & Design #39

Open DAddYE opened 11 years ago

DAddYE commented 11 years ago

things like:

a = def(int:a, int:b) { ret some }
a(1, 2)

can like in julia everything be considered as a function itself ? In that case def(a:int) can have sense.

tj commented 11 years ago

as you mentioned in the other issue about having a canonical token for any function, the reason I like def first is the uniformity it creates along the left, looks pretty nice to me at least, you don't have to lookahead to see what sort of assignment you're dealing with. It definitely does however look kinda awkward to use def as an expression but I'm all for figuring something nice out there. I also think end looks really silly for lambdas so part of me doesn't want them at all haha. The thing I love every time I'm writing C is the flat structure, I'd like that to be the norm in Luna as well, vs in js the tendency is to create very nested code since functions are so easy to throw around

sgraf812 commented 11 years ago

Just swinging by here, from a DSL point of view def is pretty distracting. Why not introduce something similar to Ruby's blocks or C# lambdas? Maybe even the Scala style of using _ as placeholder... After all, they will be one liners most of the time.