Perhaps I'm misunderstanding here, please bear with me. Ruby doesn't
have the ability to do this:
a = "test".length
a() => 4
Instead, you have to do this:
a = lambda {"test".length}
a.call()
To me it seems that the closure is first-class but the actual
function/method is not. You cannot pass non-anonymous functions as
arguments, you cannot assign them to variables, you cannot compare them
for equality, as you can in Lisp (and many other functional languages). No?
zak.wilson / gmail.com wrote:
>This looks like first class functions to me:
>
>def accgen (n)
> lambda {|i| n += i }
>end
>
>foo = accgen(5)
>foo.call(5) # returns 10
>foo.call(5) # returns 15
>
>accgen function borrowed from http://www.paulgraham.com/accgen.html
>
>Lisp macros are the main area in which Lisp has more power than Ruby,
>and are closely related to Lisp's syntax (or non-syntax). Macros allow
>for new language constructs much like OOP allows for new types, for
>example, if Common Lisp didn't have unless, you could add it like this:
>
>(defmacro unless (test &rest forms)
> `(if ,test 'nil
> ,@forms))
>
>
>
>