Why not move cast to the standard library?

language_fan foo at bar.com.invalid
Thu Sep 24 12:21:31 PDT 2009


Thu, 24 Sep 2009 21:13:48 +0200, downs thusly wrote:

> language_fan wrote:
>> Thu, 24 Sep 2009 13:47:21 -0400, Steven Schveighoffer thusly wrote:
>> 
>>> I actually prefer the compiler to handle the casting versus templates
>>> to cut down on template instantiation bloat.
>> 
>> I wonder how D scales to 100 MLOC programs as the template
>> instantiations can be troublesome already in < 1000 LOC programs.
> 
> We write templates in < 1000 LOC programs to avoid having to write 100
> MLOC :)
> 
> Also, let me categorically state: if you're writing 100MLOC programs,
> you're doing it horribly, horribly wrong.
> 
> No conceivable program possibly requires that much logic.

I agree, usually there is *something* wrong with your program if it gets 
that large. I personally do not consider programs of that size very 
reliable. But the thing is, you probably know that people fear template 
instantiations. Not only can they cause really weird linking bugs, the 
more templates you have, the larger the executables get. Also as dmd does 
not use garbage collection (yet?) during compilation, the instantiations 
can easily kill the compilation process.

Sometimes templates are abused to do what macros were supposed to by used 
for. I can imagine that templates can cause problems much sooner, you do 
not even need 1 MLOC of code to do that. Apparently D will never get a 
powerful macro system since the focus is on other features and templates 
seem to work just fine on the small scale.



More information about the Digitalmars-d mailing list