[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dynamic vs. static typing
On Nov 19, 2003, at 2:22 AM, Steve Dekorte wrote:
>>> What if I want to send a message to all the objects in the list that
>>> respond to a method, but not to those that don't? For example, let's
>>> say I have a list of things in my house and I want to send a turnOff
>>> message to everything that can be turned off.
>>
>> As Anton van Straaten explained beautifully, all the objects in this
>> case respond to some message like "turn off if you can", or "can you
>> turn off?".
>
> We'll say that all implement, say, a "respondsTo:" method (that takes
> a string argument and returns True or False) and some (but not all)
> implement a turnOff method.
>
> Can we have a type that declares that an object implements respondsTo:
> and *may* implement turnOff? If so, how does it prevent the
> possibility of a "does not respond to turnOff" error?
I noticed no one responded to this post of mine. Was it a silly
question or a difficult one for ST? :-)
-- Steve