From: Devin Mullins Date: 2005-06-29T11:34:13+09:00 Subject: Re: yield does not take a block Eric Mahurin wrote: >Having the yield keyword does >make it a little more difficult. > > Actually, it makes it a lot more difficult. Consider: irb(main):039:0> def blah irb(main):040:1> eval "yield", binding irb(main):041:1> end => nil irb(main):042:0> blah { puts 5 } 5 => nil In any case, I don't have a strong opinion on the "arity" of blocks. I *do* have a fairly strong opinion that consistency should be favored wherever possible, but nothing real to back it up, other than that (the lack of) it is what I dislike most about Java (primitives, null, Serializable, java.lang...), and it is what I like most about Ruby. >As it stands now, this code block is >actually statically typed to Proc and not just an object that >responds to call and arity. I would prefer it to be any old >duck that can call and arity. > > Agreed. That code be done without changing any of the current syntax, too. irb(main):047:0> blah(&proc{puts 5}) 5 => nil irb(main):048:0> p = Object.new => # irb(main):049:0> class << p irb(main):050:1> def call irb(main):051:2> puts 5 irb(main):052:2> end irb(main):053:1> end => nil irb(main):054:0> blah(&p) TypeError: wrong argument type Object (expected Proc) from (irb):54 from :0 Boo. :( Devin But yay, Ruby, in general. Also, yay for just having an irb session sitting around in my taskbar. Does that make me a packrat?