Generic code: @autoconst, @autopure, @autonothrow

Jonathan M Davis jmdavisprog at gmail.com
Sat Aug 28 23:32:32 PDT 2010


On Saturday 28 August 2010 21:42:49 Rainer Deyke wrote:
> On 8/28/2010 22:33, dsimcha wrote:
> >> Is there any real reason why we can't apply these modifiers
> >> automatically to all functions?  (And by "real" I don't mean "it would
> >> be hard to do" or "it is incompatible with the archaic compilation model
> >> chosen by one D implementation".)
> > 
> > Two reasons:
> > 
> > 1.  Unless the function is a template, the compiler isn't guaranteed to
> > have the source available.  What if it's a binary-only library?
> 
> "It is incompatible with the archaic compilation model chosen by one D
> implementation."
> 
> This special treatment of templates has got to end.

Templates are instantiated when you use them. They can't work any other way. 
Normal functions are instantiated where they are declared. Unless you want to 
try and make it so that _all_ functions are instantiated where they are used 
(which IMHO seems like a really _bad_ idea), templates are and must be treated 
differently. There's no way around it. It was tried with exported templates in 
C++ and that idea was shown to be horribly broken. You just can't do it.

- Jonathan M Davis


More information about the Digitalmars-d mailing list