[Issue 17379] Mangle voldemort types as if they are defined in the outer scope to avoid exponential symbol name length with templates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon May 15 04:27:25 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17379

--- Comment #5 from Georgi D <georgid at outlook.com> ---
(In reply to Rainer Schuetze from comment #4)
> > I am not sure what you mean by prepend the function name. The suggestion 
> > does not prepend the function name. Could you elaborate?
> 
> I meant that the demangler has to prepend the function name (including
> arguments to disambiguate overloads) to the identifier to print out the full
> name (if the demangled name is supposed not to show the transformation). 
> 
> > This is not meant as a special case rule. ... It is also not ambiguous since the transformation is equivalent to explicitly writing out the template.
> 
> Consider similar structs defined elsewhere, e.g. in nested or chained
> functions:
> 
> template foo(T)
> {
>    static struct Result
>    {
>       int x;
>    }
> 
>    auto fun(T t)
>    {
>       static struct Result
>       {
>          T t;
>       }
>       return Result(t);
>    }
> 
>    auto foo(T t)
>    {
>       return fun(t);
>    }
> }
> 
> What is the mangling of the return type of foo?

Yes, I did consider this case and in this sense the suggestion is for the case
where there is only one entry in the template.

The position where I started this from is:

1) regardless of how good a compression is a shorter input will generate a
shorter output. Especially if the patterns are similar.
2) looking at the chain() method in std there is an equivalent transformation
which produces shorter symbol names by taking the voldemort type outside of the
method.
3) my first impulse was to create a pull request for phobos and make the
trasformation as a code change
4) following the path of 3) though would have meant removing all voldemort
types from phobos and in effect discouraging them in template code.
5) since I did not like 4) I considered the option of the compiler making the
transformation without the need of a code change.

The feature can be made more generic if we use a generated name for the
voldemort types which are not supposed to be visible except by the compiler
anyway.

--


More information about the Digitalmars-d-bugs mailing list