Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like the fact that you can substitute a more complex expression anywhere, even in the first position (the function to be called), but everything looks so similar that it's hard to see what's going on. I read more code than I write (I like to read about programming languages) and this:

((lambda (x y) (+ x y)) 3 4)

looks much harder to read than this:

(function(x, y) return x+y end)(3, 4).

In the Lua version, you can easily skim the code: here is a function (rather than a Greek letter), the parameters are inside parenthesis and separated by commas, the body comes next until the "end" keyword, it produces (returns) a value and then you pass the parameters (inside parenthesis and separated by commas again) to the function that was just created.

In the Scheme version, how am I supposed to know where this lambda ends other than counting parenthesis and having a lot of practice to recognize that (....... thing thing) is a function call where the function is more than a single name?

Similarly this:

(define (fn x) (lambda (a) (+ a x)))

IMHO looks much harder to read than this:

function fn(x) return function(a) return a+x end end

The second one is much clearer: "return function", you are returning a closure to the caller. The Scheme one makes me think: a function, another function, parenthesis, an expression, then it ends abruptly and I don't know what the hell the code supposed to do. Again, I CAN read that code in Scheme, but only after learning the core concepts in Lua.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: