Less Code Bloat from Templates

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 31 14:32:45 PDT 2014


On Friday, 31 October 2014 at 20:06:57 UTC, H. S. Teoh via
Digitalmars-d wrote:
> On Fri, Oct 31, 2014 at 07:47:29PM +0000, deadalnix via 
> Digitalmars-d wrote:
>> That is basically generic à la java.
>> 
>> I'd like to see what can be done in term of library on that 
>> front
>> as I suspect that we can get quite far.
>
> What would be more interesting IMO, is to explore ways of 
> automating
> this so that a fully-generic template can be factored out into
> type-dependent parts and type-independent parts. While type 
> erasure is
> advantageous in some circumstances, they are problematic in 
> other
> circumstances. Similarly, while D's full templating system 
> works well
> where type erasure is lacking, it also suffers from template 
> bloat.
> Ideally, the best of both worlds should lie somewhere in 
> between.
>
>
> T

Compiler have some capability to merge identical IR, and linker
identical codegen. But that tend to be expensive, and going the
type erasure road is a worthwhile option in many cases.


More information about the Digitalmars-d mailing list