From: dblack@... Date: 2003-02-21T21:22:05+09:00 Subject: Re: proc {} vs. Method#to_proc Hi -- On Fri, 21 Feb 2003, Mauricio [iso-8859-1] Fern�ndez wrote: > On Fri, Feb 21, 2003 at 06:03:38AM +0900, dblack@candle.superlink.net wrote: > > Hi -- > > > > On Fri, 21 Feb 2003, Mauricio [iso-8859-1] Fern�ndez wrote: > > > > > On Fri, Feb 21, 2003 at 01:19:17AM +0900, dblack@candle.superlink.net wrote: > > > > Hi -- > > > > > > > > Arising from a recent discussion on #ruby-lang: > > > > > > > > Proc objects created by Method#to_proc seem to care about their arity > > > > in a way that other Proc objects don't. To illustrate: > > > > > > Procs don't care about the arity when they are transformed into blocks > > > with '&': unneeded arguments are discarded and if there's not enough > > > they get filled with nil. > > > > But that isn't what's happening with the to_proc procs. That's why > > their behavior strikes me as anomalous. > > Read the rest of my message :) > > to_proc works like > proc { |*args| self.call(*args) } > calling the block works (it accepts any number of args, so even .call > would), self.call fails. > > You can use #my_to_proc in [ruby-talk:65372] to make these procs behave like the > others. I understand that (we were already playing around with reimplementations in the original irc session on this :-) but my point was that I think that the behavior of these procs is potentially misleading and I wonder whether it should (or could) be changed in the language itself. Somehow "to_proc" doesn't convey the idea of a wrapper of this kind to me. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav