What to do about default function arguments

Walter Bright newshound2 at digitalmars.com
Thu Apr 26 00:54:27 PDT 2012


On 4/26/2012 12:47 AM, Timon Gehr wrote:
> On 04/26/2012 05:44 AM, Walter Bright wrote:
>> A subtle but nasty problem - are default arguments part of the type, or
>> part of the declaration?
>>
>> See http://d.puremagic.com/issues/show_bug.cgi?id=3866
>>
>> Currently, they are both,
>
> That is how it should be.
>
>> which leads to the nasty behavior in the bug report.
>>
>
> It contributes, but it is not the main cause.
>
>> The problem centers around name mangling. If two types mangle the same,
>> then they are the same type.
>
> Then they are equal types.

This is simply not tenable. What defines when they are "equal" types and when 
they are "not equal"? Consider a pointer to a function. Are the default 
arguments part of its type? If it compares "equal" to another type without 
default arguments, which is the real type (such as the result of ?:) ?


>> But default arguments are not part of the
>> mangled string. Hence the schizophrenic behavior.
>>
>
> The schizophrenic behavior occurs because the types cross-talk. Are mangled
> names kept unique in the compiler or what is the implementation issue exactly?

It's a conceptual issue. When is one type the same as another, and when is it not?



More information about the Digitalmars-d mailing list