So, User-Defined Attributes

Max Samukha maxsamukha at gmail.com
Fri Jan 4 09:48:05 PST 2013


On Friday, 4 January 2013 at 17:11:04 UTC, Philippe Sigaud wrote:
> The declaration. The type, I guess I'd use an alias. Though, I 
> guess the
> alias syntax limitations would probably forbid that.
>
> So yes, the local declaration is attributed, that works. How do 
> I propagate
> the attribute to the returned value?

I think you cannot.

>
>
> Also, dropping the auto return is not accepted by the compiler, 
> even though
>>> it seems natural for me:
>>>
>>> @(__traits(getAttributes, origin)) To 
>>> transferAttributes(alias origin,
>>> To)(To t)
>>> {
>>>     @(__traits(getAttributes, origin)) To temp = t;
>>> ...
>>>
>>> 'origin' is a template parameter and should be reachable to 
>>> determine the
>>> return type.
>>>
>>
>> That's a bug.
>
>
> Already filed?

Don't think so.

>
>
>
>> Anyway, you are attributing the function declaration here, not 
>> the return
>> type
>
>
> Hmm. Would @(attr) { ReturnType } functionName (...)  work?
>

It looks we simply cannot modify existing declarations with UDAs.

@(attr) alias foo = bar; // @(attr) is ignored.

It is inconsistent with builtin attributes, which can create 
modified declarations out of existing ones. I am not sure whether 
it is a real problem.







More information about the Digitalmars-d mailing list