3 ms·
Ruby has at least 1. and 3. 1. "usable global variables" exist in two forms; the rarely used $ sigil, as in $foo (automatically global), and the more commonly
by rst 16y ago
Ruby has at least 1. and 3.
1. "usable global variables" exist in two forms; the rarely used $ sigil, as in $foo (automatically global), and the more commonly used hack of defining attributes and accessors on a class (for which there's standard macrology, cattr_accessor, in Rails).
3. Everything he mentions as properties of Lisp closures is commonly done with Ruby blocks (modifying variables in enclosing scopes; use of "return" in a block to return from the enclosing method).
That leaves the condition system. I'm not aware of another commonly used environment that lets you say, for instance, "if you were about to throw a FileNotFound exception, try doing this instead first". But unlike the other two, I'm not sure that's a feature of Lisp dialects in general, as Common Lisp in particular...
- loewenskind 16y agoSmalltalk has restartable exceptions, but they're not as nice as CL's condition system.
- technomancy 16y agoYou're missing the point of 1. It's not simply "you can use globals", it's that you can rebind them in a thread-isolated way that stacks. Ruby blocks aren't really first-class without getting converted into procs, and it's pretty un-idiomatic to pass these around like actual values. Even then they're not "first-class" as most calls happen via method calls rather than function invocation.