From: ara.t.howard@... Date: 2006-07-26T06:35:26+09:00 Subject: Re: I'll have the duck! On Wed, 26 Jul 2006, Benjohn Barnes wrote: > *nods* I tend to agree. When I posted earlier, it certainly seemed like the > person I replied to had "gone beyond" or "gone elsewhere" from what I > understand by the term "duck typing". As I said, it seemed a lot like > prototype classes (adding capabilities to something based on the fact that > it already has certain capabilities). I'd also agree that duck typing is a > practice; you can do it with c++ templates, for instance, as far as I can > see. sortof. even if you ignore the compile-time vs run-time semantics between ruby and c-- you still get nailed with 'method_missing' which may well respond to any message sent: harp:~ > cat a.rb class BlackBox instance_methods.each{|m| undef_method m} def method_missing(m, *a, &b) 42 end end %w( fee fie fum __id__ __send__ ).each{|m| p(BlackBox.new.send(m))} harp:~ > ruby a.rb 42 42 42 42 42 this is a crucial distinction between any generic programming methodology or interface paradigm - this is really sending a message to an object which may do just about anything with it. regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama