Policy for exposing range structs
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Fri Mar 25 11:20:12 PDT 2016
On 3/25/16 12:18 PM, H. S. Teoh via Digitalmars-d wrote:
> On Fri, Mar 25, 2016 at 11:40:11AM -0400, Steven Schveighoffer via Digitalmars-d wrote:
>> On 3/25/16 11:07 AM, Andrei Alexandrescu wrote:
>>> On 3/25/16 10:07 AM, Steven Schveighoffer wrote:
>>>>
>>>> We should actually be moving *away from* voldemort types:
>>>>
>>>> https://forum.dlang.org/post/n96k3g$ka5$1@digitalmars.com
>>>>
>>>
>>> Has this bug been submitted? -- Andrei
>>
>> I'm not sure it's a bug that can be fixed. It's caused by the design
>> of the way template name mangling is included.
>>
>> I can submit a general "enhancement", but I don't know what it would
>> say? Make template mangling more efficient? :)
>>
>> I suppose having a bug report with a demonstration of why we should
>> change it is a good thing. I'll add that.
> [...]
>
> We've been talking about compressing template symbols a lot recently,
> but there's a very simple symbol size reduction that we can do right
> now: most of the templates in Phobos are eponymous templates, and under
> the current mangling scheme that means repetition of the template name
> and the eponymous member in the symbol. My guess is that most of the 4k
> symbol bloats come from eponymous templates. In theory, a single
> character (or something in that vicinity) ought to be enough to indicate
> an eponymous template. That should cut down symbol size significantly
> (I'm guessing about 30-40% reduction at a minimum, probably more in
> practice) without requiring a major overhaul of the mangling scheme.
I don't think it's that simple. For example:
auto foo(T)(T t)
Needs to repeat T (whatever it happens to be) twice -- once for the
template foo, and once for the function parameter. If foo returns an
internally defined type that can be passed to foo:
x.foo.foo.foo.foo
Each nesting multiplies the size of the symbol by 2 (at least, maybe
even 3). So it's exponential growth. Even if you compress it to one
character, having a chain of, say, 16 calls brings you to 65k characters
for the symbol. We need to remove the number of times the symbol is
repeated, via some sort of substitution.
Added the bug report. Take a look and see what you think.
https://issues.dlang.org/show_bug.cgi?id=15831
-Steve
More information about the Digitalmars-d
mailing list