dynamic classes and duck typing
Walter Bright
newshound1 at digitalmars.com
Tue Dec 1 11:07:15 PST 2009
Bill Baxter wrote:
> I forgot a biggie: with opDispatch you must know the return type at
> compile time.
> You could make the return type be Variant or something, but then that
> makes it quite different from a "regular" function.
> Whereas in a dynamic language like Javascript a dynamic method looks
> just like a regular method (because they're all dynamic, of course).
The Javascript implementations use variants for all variables, values,
and function returns. So it isn't any different from defining opDispatch
to take and return Variant's.
std.variant needs to be extended with opDispatch so it can execute a
call operation on a Variant, then it will be very very similar to
Javascript.
More information about the Digitalmars-d
mailing list