Function pointers/delegates default args were stealth removed?

Artur Skawina art.08.09 at gmail.com
Mon Aug 27 15:14:51 PDT 2012


On 08/27/12 13:46, Timon Gehr wrote:
> On 08/27/2012 01:16 PM, Artur Skawina wrote:
>> On 08/27/12 12:54, Timon Gehr wrote:
>>> On 08/27/2012 10:48 AM, Piotr Duda wrote:
>>>> 2012/8/27 Walter Bright <newshound2 at digitalmars.com>:
>>>>> On 8/26/2012 11:14 PM, Piotr Duda wrote:
>>>>>>
>>>>>> Default args should be part of types (for passing them as template
>>>>>> args etc, implicity convertable if they differs only on defaults) but
>>>>>> not mangled in (since mangling is revelant only for linking, where
>>>>>> defaults doesn't matter).
>>>>>
>>>>>
>>>>> And then there's a list of other bugs that show up. Now you have two
>>>>> different types showing up as the same type (i.e. name) to the linker, and
>>>>> you've got weird collisions.
>>>>
>>>> For linker these types should be identical, so there shouldn't be any
>>>> collisions, unless D handles default args fundamentally different than
>>>> C++.
>>>>
>>>
>>> You said they should be part of the type for passing as template args:
>>>
>>> auto foo(T)(T dg){
>>>      return dg();
>>> }
>>>
>>> // therefore
>>> assert(foo((int x=2)=>x)==2); // this instantiation
>>> assert(foo((int x=3)=>x)==3); // must differ from this one
>>> // ergo, they cannot have the same mangled symbol name!
>>
>> Anonymous functions must be unique anyway.
> 
> What is the point?

I misunderstood, my fault, sorry.

A template instantiation with a parameter containing a default
argument must of course reflect that argument in the mangled name.
Are there other cases where def-args can't be ignored? (not where
they are just "lost", that is not a problem)

artur


More information about the Digitalmars-d mailing list