dynamic classes and duck typing

Leandro Lucarella llucax at gmail.com
Sun Nov 29 14:39:16 PST 2009


Walter Bright, el 29 de noviembre a las 13:52 me escribiste:
> Leandro Lucarella wrote:
> >Walter Bright, el 27 de noviembre a las 15:30 me escribiste:
> >>One thing Java and Python, Ruby, etc., still hold over D is dynamic
> >>classes, i.e. classes that are only known at runtime, not compile
> >>time. In D, this:
> >
> >I like the feature, but I don't understand where is the duck-typing in all
> >this. I think you're confusing duck-typing with dynamic-typing or I'm
> >missing something?
> 
> Perhaps I am using the term wrong, but I figure it's duck-typing if
> you can go ahead and try to access methods of an object, and they
> are checked at runtime and throw some kind of method-not-found
> exception if they aren't there.

OK, now I see what you mean. Perhaps it would be helpful to have
a standard exception for unexistent methods to support that idiom. If we
don't every library will create one and it would be a mess.

A standard way to test if a method exists would be nice too, something
like Python's getattr(), setattr() and hasattr() can be a start.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Demasiado lento para una estrella fugaz
Demasiado limpio para lo que vos acostumbras
Demasiado claro para tanta oscuridad
Demasiados sueños, poca realidad



More information about the Digitalmars-d mailing list