Fun with range deprecations

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 13 09:36:21 PDT 2014


On Wed, Aug 13, 2014 at 08:54:09AM +0000, John Colvin via Digitalmars-d wrote:
> On Tuesday, 12 August 2014 at 19:15:48 UTC, H. S. Teoh via Digitalmars-d
> wrote:
> >On the positive side, if these "optional" range methods are
> >templatized, they will reduce template bloat in code that doesn't
> >need to use them.  AFAIK, if you have a template struct with 10
> >methods, all 10 will get instantiated when you instantiate the
> >struct, even if you only ever use 3 of them in your code. So it seems
> >to be a good thing to templatize the "additional" methods like .save,
> >.back, .popBack, .opIndex, which may never get used if the user only
> >ever needs the input range methods.
> 
> 
> templates to _reduce_ code size, I'd never thought of that before
> (although really this is work that a linker can do).

Having the linker do this is kinda patching things over after the
problem has already occurred IMO. Not emitting the code in the first
place beats emitting it only to discard it later.


T

-- 
Ruby is essentially Perl minus Wall.


More information about the Digitalmars-d mailing list