From: ahoward Date: 2003-01-19T01:50:16+09:00 Subject: Re: quick: it responds, it evaluates, and is not empty On Sat, 18 Jan 2003 dblack@candle.superlink.net wrote: > Well, "random" is a bit extreme... :-) My main focus in all of this > is to explore ways of making it easier and faster to do something > which I think is very natural for Ruby, namely to handle situations > based on the capabilities and responses of the objects present at > a given point. > > In particular, I think part of the difficulty in trying to convince > people not to rely on explicit type-checking in Ruby is that there's > no really compelling, precise alternative. The double-barreled > "respond_to?"/method-call is, well, double-barreled, and the exception > wrapper is slow and inexact. it seems like what you are after then are dynamic interfaces, after all wouldn't if object.implements? interface ... # does it implement all of an interface or even if objects.implements? interface.method :sym ... # does it implement a method from this interface, eg with same args, etc. if they existed, would solve all of this. it's true this is not the same as NACK but you wouldn't need NACK if one could tell if an object implemented some sort of interface would you? checking if and object did implement and interface wouldn't really be that different from respond_to? but it would consoldate it considerably and result in quite readable, brief code i think. i think i am going to go back and re-read some of the interface threads, does anyone know of any work being done to this ends? i seem to recall the main issues were validating arity and argument types... -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================