dynamic classes and duck typing

Don nospam at nospam.com
Wed Dec 2 08:16:26 PST 2009


Bill Baxter wrote:
> On Tue, Dec 1, 2009 at 11:43 AM, Don <nospam at nospam.com> wrote:
>> Bill Baxter wrote:
>>> On Tue, Dec 1, 2009 at 5:18 AM, Lutger <lutger.blijdestijn at gmail.com>
>>> wrote:
>>>> Ary Borenszweig wrote:
>>>>>>>>> The feature isn't very dynamic since the dispatch rules are defined
>>>>>>>>> statically. The only thing you can do is rewire the associative
>>>> I don't get it, what if WhatTypeToPutHere does a dynamic lookup, then
>>>> it's
>>>> pretty much the same a Javascript isn't it? Except that everything in
>>>> Javascript does dynamic lookup and in D you are restricted to types that
>>>> have this dynamic lookup (which, pending a phobos solution you have to
>>>> code
>>>> yourself). Do you mean to say this 'except' is the obstacle somehow?
>>>>
>>>> How is that less dynamic? You would be able to call or even redefine at
>>>> runtime, for example, signals defined in xml files used to build gui
>>>> components.
>>> It is a bit less dynamic because in D it's all done with templates.
>> It's a helluva lot more dynamic in D because it can do code generation on
>> request. The "dynamic" bit in Javascript is really an AA lookup, +
>> reflection.
> 
> But that's code generation /at compile time/.
> You can call that "more dynamic" if you like, but it seems to fall
> more in the realm of what is considered "static" to me.
> Doesn't mean it's not really useful, but calling it dynamic seems to
> be stretching the traditional definition a bit too far.
> 
> --bb

Yeah, it's all about naming. The thing is, the traditional "dynamic" 
isn't very dynamic. You can't *really* add new functions at run-time. 
They all exist in the source code, all you're doing is manipulating 
function pointers, and the dynamic thing is just syntax sugar for that. 
If you have a language with a built-in compiler or interpreter, it can 
be truly dynamic, but I don't think that's the normal use of the term.



More information about the Digitalmars-d mailing list