What's wrong with D's templates?

Yigal Chripun yigal100 at gmail.com
Mon Dec 21 21:52:20 PST 2009


On 22/12/2009 05:22, Walter Bright wrote:
> Kevin Bealer wrote:
>> The performance / impl-hiding conflict is a fundamental problem -- if
>> the user's compiler can't see the template method definitions, then
>> it can't optimize them very well. If it can, then the user can too.
>> Any method of compiling them that preserves enough info for the
>> compiler to work with will probably be pretty easily and cleanly
>> byte-code-decompilable.
>
> Absolutely right.
>
> One of the features that C++ exported templates was supposed to provide
> was obfuscation of the template bodies so that users couldn't see it. My
> contention was that there was essentially no reasonable method to ensure
> that.
>
> 1. any obfuscation method only has to be cracked by one individual, then
> everyone can see through it.
>
> 2. if you ship the library for multiple compilers, you only have to
> crack the weakest one
>
> 3. if you provide the decryption key to the customer, and you must, and
> an open source compiler is used, you lose

You can also dis-assemble binary libs. That's not the point of this 
discussion. The point is having proper encapsulation.



More information about the Digitalmars-d mailing list