On Sat, 17 Feb 2007, Stefan Rusterholz wrote:

>
> With current implementation, the only way to figure if an object can be
> dup'ed is by dup it and catch the exception. I don't know how imperative
> duck-typing is for ruby, but this way actively prohibits it.  The method
> signature of those classes suggests it can be dup'ed, but "hidden" in the
> code it actually shows that it isn't. That's in my oppinion intransparent.
> As said before, the issue can be worked around (as you say e.g. via
> exception handling), but following your argument, my question would be: why
> implement a method that can't be executed?

because, in ruby, all methods can be changed all the time:

   class C
     def dup() raise "now you can't" end
   end

   c = C.new

   c.dup rescue nil

   class << c
     def dup() raise "now you can" end
   end

   c.dup

just because an object responded to a message one time, at compile time, or
whatever - doesn't mean it will later.  this is the dynamic in 'dynamic
languages.'

note that being able to dump singleton classes doesn't change this one bit.

regards.


-a
-- 
we can deny everything, except that we have the possibility of being better.
simply reflect on that.
- the dalai lama