Policy for exposing range structs

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 31 20:08:17 PDT 2016


On Thursday, March 31, 2016 09:10:49 Steven Schveighoffer via Digitalmars-d 
wrote:
> On 3/30/16 3:19 PM, Liran Zvibel wrote:
> > On Sunday, 27 March 2016 at 17:01:39 UTC, David Nadlinger wrote:
> >> Compression in the usual sense won't help. Sure, it might reduce the
> >> object file size, but the full string will again have to be generated
> >> first, still requiring absurd amounts time and space. The latter is
> >> definitely not negligible for symbol names of several hundreds of
> >> kilobytes; it shows up prominently in compiler profiles of affected
> >> Weka builds.
> >
> > We love Voldemort types at Weka, and use them a lot in our
> > non-gc-allocating ranges and algorithm libraries. Also, we liberally
> > nest templates inside of other templates.
> > I don't think we can do many of the things we do if we had to define
> > everything at module level. This flexibility is amazing for us and part
> > of the reason we love D.
>
> Voldemort types are what cause the bloat, templates inside templates
> aren't as much of a problem. It's because the Voldemort type has to
> include in its symbol name at least twice, and I think 3 times actually
> (given the return type), the template parameter/function parameter types
> of the function it resides in. If the template is just a template, it's
> just included once. This is why moving the type outside the function is
> effective at mitigation. It's linear growth vs. exponential.

This makes me wonder if there would be a sane way to basically treat the
Voldemort type as if it were outside the function it was declared from a
mangling standpoint while still treating its accessibility the same way.
Maybe that wouldn't work due to potential name clashes, but if the problem
is purely because the type is declared inside the function, I would think
that it would make sense to try and find a way to treat it more like it was
declared outside the function when dealing with the name mangling. Then - in
theory - you'd get the benefits of using a Voldemort type while getting the
name mangling cost that you get when you declare a private type outside of
the function.

- Jonathan M Davis



More information about the Digitalmars-d mailing list