Fully dynamic d by opDotExp overloading

Don nospam at nospam.com
Fri Apr 17 12:54:52 PDT 2009


Andrei Alexandrescu wrote:
> Don wrote:
>> Andrei Alexandrescu wrote:
>>> I think there's merit in binding via strings. It makes for very 
>>> flexible code that is future-proof, dynamic-linking-friendly, and 
>>> hot-swappable without recompiling (e.g. you don't need to recompile 
>>> because you now implement an interface etc.) 
>>
>> Does that still apply to the template version you proposed?
> 
> Of course. The template version includes the version that only does 
> dynamic lookup: you can do static, and you can do dynamic. The static 
> part allows you e.g. to optimize some cases if you so wish. With the 
> runtime string you can only do dynamic.

I was thinking that, for example, in a DLL, the DLL needs to include a 
compiled version of each function name it uses; in the non-template 
version there are no new compiled version.
I haven't thought through the implications of this. I guess that it's 
really no different to foo!("funcname")(args), though.
Makes __traits(membersOf) rather interesting -- not necessarily a pure 
function, might change with time!

> 
> Again, making it a template in this case is a win-win thing. There's 
> nothing inferior about it.

I have no doubt it's better for D. I think it's the only option which is 
viable in a statically-typed language.

> 
> 
> Andrei



More information about the Digitalmars-d mailing list