__traits(getAttributes, ...) gets attributes for the first overload only

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 6 17:35:49 PST 2015


On 12/06/2015 08:13 PM, Vladimir Panteleev wrote:
> On Sunday, 6 December 2015 at 02:00:30 UTC, Andrei Alexandrescu wrote:
>> On 12/5/15 7:41 PM, John Colvin wrote:
>>> On Saturday, 5 December 2015 at 20:44:40 UTC, Andrei Alexandrescu wrote:
>>>> Working on the big-oh thing I noticed that for an overloaded function,
>>>> __traits(getAttributes, ...) applied to overloaded functions only
>>>> fetches attributes for the first syntactically present overload. Bug
>>>> or feature?
>>>>
>>>> Andrei
>>>
>>> In an ideal world I would want it to be an error to use
>>> __traits(getAttributes, ...) on anything ambiguous, would catch the odd
>>> bug. The current behaviour is dumb, but some union of attributes over
>>> the overload sets seems worse.
>>
>> Yah, error is the way to go. -- Andrei
>
> The potential problem I see with this idea is that adding an overload to
> an otherwise non-overloaded function might break some code elsewhere
> which queries the function's attributes. In other circumstances, adding
> an unambiguous overload is never a breaking change, right?

Well what if you add it before the existing function? -- Andrei



More information about the Digitalmars-d mailing list