A modest proposal: eliminate template code bloat

Marco Leise Marco.Leise at gmx.de
Sun Apr 8 09:16:41 PDT 2012


Am Sun, 08 Apr 2012 16:21:14 +0200
schrieb Artur Skawina <art.08.09 at gmail.com>:

> On 04/08/12 13:01, Dmitry Olshansky wrote:
> > 3. After any function was generated compiler checks an entry in the duplicate table that matches size, followed by matching checksum and only then (if required) doing a straight memcmp. If it happens that there is a match compiler just throws generated code away and _aliases_ it's symbol to that of a matched entry.
> > (so there has to be an alias table if there isn't one already)
> [...]
> > Thoughts?
> 
> Don't forget that this needs to work:   
> 
>    static auto f(T)(T a) { return a; }
>    assert(cast(void*)&f!int!=cast(void*)&f!uint);
> 
> artur

Do you actually rely on that behavior? It is the same as asking this to work, I think:

string a = "abc";
string b = "abcdef";
assert(a.ptr !is b.ptr);

There should be ways to logically check the unequality of your two functions, not by comparing their memory addresses.

-- 
Marco



More information about the Digitalmars-d mailing list