D's templates now seem weak to me...

Ben Phillips Ben_member at pathlink.com
Mon Feb 20 09:55:48 PST 2006


In article <dtcr4g$254q$1 at digitaldaemon.com>, Stewart Gordon says...
>
>Ben Phillips wrote:
>> According to the docs, "Templates cannot be used to add non-static members or
>> functions to classes. For example: [...]". Why? This is just plain stupid in my
>> opinion
>
>Because at the time of compiling the module, one cannot be sure what 
>types it will be called on, and so it wouldn't be able to generate the vtbl.
>
>However, it ought to be possible to do it on private and final member 
>functions, since such things will never be overridden and so don't need 
>to be included in the vtbl.
>

That makes sense. However, couldn't this be fixed by just not compiling the
template functions when creating a *.lib? The end user has to import the
appropriate files anyways so it should be possible for the compiler to delay
compilation of the functions until an executable is made (kind of like C++
though C++ uses preprocessor #includes)





More information about the Digitalmars-d mailing list