From: "Avdi B. Grimm" Date: 2001-10-24T08:03:11+09:00 Subject: [ruby-talk:23118] Re: Bruce Eckel's opinion of Ruby On Tue, 2001-10-23 at 16:25, Michael Neumann wrote: > meth_b = a.method(:b) > > meth_b.call() # => "b" Ditto this. I'm surprised by how often this feature gets overlooked. Taking Python's (current) lack of real closures (I.E. lambda's don't bind to local variables inside the scope in which they are created), there's simply no comparison between Python and Ruby's functional programming capabilities. > > 10. Reference counting works hand-in-hand with Python's destructors to handle > > resource cleanups in a real-time manner that's difficult with Ruby (where you > > can set up destructors of a sort but they only run at garbage collection > > time, which may be some time later, in the meantime you still have some open > > files and files on disk hanging around that are not getting cleaned up). > > Use the block paradigm instead. E.g. > > DBI.connect do | dbh | > # do something with dbh > end > > or > > File.open(fileName, "r") do | file | > # ... > end > > Using this there is no need for destructors. I have to disagree with this statement. There *are* cases where the block paradigm is simply not appropriate, and destructors are. Sometimes it's possible to kludge in a solution using the block paradigm; but it's not pretty. It's not a terribly rare occurance to have objects which (a) /must/ release resources before being garbage-collected, and (b) have non-determinate lifetimes. ~Avdi