News for hackers. Stuff that matters.
Re:Lisp in 32 lines of Ruby by marijn on Wednesday January 25, 2012 @03:04PM (#3511467)
He seems to have forgotten lambda, without which you can't really write anything more interesting than the examples that are given.
Re:Lisp in 32 lines of Ruby by mapgrep on Wednesday January 25, 2012 @03:10PM (#3511490)
I thought this was his example of lambda:

  l.eval [:label, :second, [:quote, [:lambda, [:x], [:car, [:cdr, :x]]]]]
No?
Re:Lisp in 32 lines of Ruby by indspenceable on Wednesday January 25, 2012 @10:04PM (#3512733)
Can someone explain how this works?

I understand that (label second '(...)) makes second evaluate to that in the future, statefully, but, the lambda symbol doesn't even appear to have a definition; furthermore, if you try to use it in a way that would work with a real lambda, it doesn't work.

For instance [[:lambda, [:x], :x], 2]

Re:Lisp in 32 lines of Ruby by TomasSedovic on Thursday January 26, 2012 @04:40AM (#3513468)
Take a look at the second line in the `apply` definition[1]:

    self.eval @env[fn][2], Hash[*(@env[fn][1].zip args).flatten(1)]
It's triggered when the `fn` is not callable, i.e. when we pass in lambda:

    [:lambda, [:x], [:car, [:cdr, :x]]]
The code ignores the `:lambda` symbol (that would be `@env[fn][0]`).

It evals the third element of the list (the lambda body) in a new context that combines `@env` and the binding of lambda's args to the symbols in the lambda's definition -- that's what the `Hash` mumbo jumbo creates.

[1]: https://github.com/fogus/ulithp/blob/b02d5806ce3b2d3766311c2...

Re:Lisp in 32 lines of Ruby by fogus on Wednesday January 25, 2012 @03:10PM (#3511492)
Even the example using lambda?