From: Bob Hutchison Date: 2001-12-31T23:23:37+09:00 Subject: [ruby-talk:29855] Re: Proc.class vs yield On 12/31/01 8:42 AM, "Michael Lucas-Smith" wrote: > That's a good solution, thanks. > But I have to say I'm slightly confused as to why everybody seems so > against having the Ruby language hide the fact that you're either > dealing with a block or a proc. > Why must there only be one? Why do you have to use the keyword proc to > define a new proc from a block? > > The common case is to pass a block around, but when you need it to act > like an object, you have to turn it in to a proc. I'm all for > optimisation. So why can't Ruby do it for you - if the method takes >1 > parameters and you hand it some blocks, can't it turn them in to procs > for you? (taking in to account the & logic to accept the yield block as > a proc) > > Michael > I think you are trying to do something like the following. Note that the block is there for demonstration purposes, if you don't want a block don't use it (and in your example I'd probably stick to procs). This combined with default values might be interesting to think about. def procWithBlock(p1, p2) p1.call p2.call yield end procWithBlock((proc { printf "hello from proc one\n" }), (proc { printf "hello from proc two\n" })) { printf "hello from block\n" } Anyway, I don't think the syntax here is too bad. If I understand your point here, that the 'proc's in the method call should be put there automatically by the compiler, then I think I agree (but I don't think it all that important) Cheers, Bob ~