[dmd-internals] Type mangling for deduced attributes

Don Clugston dclugston at googlemail.com
Wed Nov 16 00:31:51 PST 2011


On 16 November 2011 03:23, kenji hara <k.hara.pg at gmail.com> wrote:
> 2011/9/4 Walter Bright <walter at digitalmars.com>:
>>
>>
>> On 9/3/2011 5:56 PM, Martin Nowak wrote:
>>>
>>> I've stumbled over the fact that deduced function attributes (pure,
>>> nothrow) are not reflected
>>> in the name mangling. Is this a bug or by design?
>>>
>>
>> It is by design. I think that's the right choice, but I'm not positive.
>
> I think .mangleof property should return the actual value (based on
> the real type).
> Otherwise, we cannot guarantee the pure/nothrow/safe attributes in ABI level.

That's intentional. If it is only *deduced* to be pure/nothrow/safe,
then external functions, which don't have access to the source, can
NOT rely on it being pure/nothrow/safe. I think this is the right
choice.
Suppose I want to declare a stub function. At the moment, because it's
just a stub, it isn't impure or unsafe, but I know that when it is
fully implemented, it will be impure and unsafe, and may throw.
The deduction should not be giving additional guarantees to external
code. It should be conservative.


More information about the dmd-internals mailing list