From: Clemens Wyss Date: 2001-11-13T17:28:55+09:00 Subject: [ruby-talk:24988] Re: Linux Magazine article > Disclaimer: I also don't know LISP or Smalltalk, so I don't > know whether similar things exist there (though I wouldn't > be surprised). Smalltalk does it (blocks [], iterators), too ;-) e.g.: 'myCollectionObject forEachDo: [ :element | ... ]' And the implementation of the 'forEachDo:' method might be 'forEachDo: aBlock elements do: [ :element | aBlock value: element ]' A 'non iterating example' w.o. exception handling: 'open: fileName mode: aMode do: aBlock fh := File open: fileName mode: aMode. aBlock value: fh. fh close' Note: - Smalltalk blocks are Ruby's BlockClosures - value: is Ruby's call - 'do:' is THE iterator method of Collection classes. - Smalltalk (as Ruby) also has detect:, select:, inject: ,... Pretty sure matz has "taken" these concepts from Smalltalk ;-) I(coming from Smalltalk and still loving Smalltalk, too) must also admit that 'Block(Closure)s' are one of the many attractions of Ruby. Other Ruby highlights: - pure OO - "open classes" - mixin-mechanism (Modules) - very strong introspection/reflection mechanisms - eval ;-) - matz and the other bright and friendly 'gurus' of ruby-talk/c.l.r. Regards Clemens