From: Austin Ziegler Date: 2004-03-02T04:05:53+09:00 Subject: Re: concerns about Proc,lambda,block On Tue, 2 Mar 2004 03:23:41 +0900, David A. Black wrote: > Hi -- > > > On Tue, 2 Mar 2004, ts wrote: > > >>>>>>> "D" == David A Black writes: >>>>>>> >> >> D> I think Dave's explanation is about as good as one can give -- and >> D> that's what worries me. In particular, the fact that Ruby is now D> >> doing something that requires the concept of "contexts" to explain D> >> strikes me as an indication of a possible problem. >> >> Well, the problem is perhaps that he try to rationalize (he must be >> cartesian :-)) when you must "visually" see the examples. >> > > But there isn't any visual information to go on, once these objects leave > the site of origin. Nor do the objects differentiate themselves very > clearly: > > irb(main):012:0> n.methods - m.methods > => [] > irb(main):013:0> n.class == m.class > => true > irb(main):014:0> n.arity == m.arity > => true > irb(main):015:0> n.call > ArgumentError: wrong number of arguments (0 for 2) from (irb):15:in `x' > from (irb):8:in `call' from (irb):15 irb(main):016:0> m.call => nil > irb(main):017:0> RUBY_VERSION => "1.9.0" > > There's nothing wrong with having code blocks/closures that behave > differently. But it isn't represented in the language the way that other > such differences between built-ins are. (And the actual rules having to > do with arity also seem very complex to me.) I think that what's more bothersome to me is that there doesn't appear to be a way to convert one type of Proc to another. I can't do: n.argument_style(:yield) or n.argument_style(:method). -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2004.03.01 * 14.02.40