From: Eric Mahurin Date: 2005-06-29T08:23:47+09:00 Subject: Re: yield does not take a block --- Ryan Leavengood wrote: > Eric Mahurin said: > > > > As it is now, you can > > pass a block to just about any method that doesn't want a > block > > and no complaint will be given. > > There will also be no bad side affects, besides the code in > the block is > never executed. So essentially the person does not > understand the > interface to the given method. I don't agree the language > should enforce > this, especially given the dynamic nature of Ruby. In fact > this reminds me > of all the static-typing sort of arguments we get here now > and then. > > I equate the above argument to someone saying this should > give a warning: > > false && a_very_important_method_call() > > A language can only go so far in trying to stop bad > programmers before it > starts hurting good programmers. You could say the same thing about passing too many arguments to a method. Why does Ruby check this case now? ... because it is an obvious error that can easily be checked for. The same could be done automatically for code blocks to methods - with the right language changes. Having the yield keyword does make it a little more difficult. I have no idea what this has to do with static typing. I am a very strong proponent of duck typing. We are talking about whether a certain argument (the code block) exists in the call not what type it is. 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. __________________________________ Discover Yahoo! Stay in touch with email, IM, photo sharing and more. Check it out! http://discover.yahoo.com/stayintouch.html