Ordering of UDAs

Adam D. Ruppe destructionator at gmail.com
Mon Apr 22 19:32:27 UTC 2019


On Monday, 22 April 2019 at 19:02:57 UTC, Emmanuelle wrote:
> Hello! Does `__traits(getAttributes, ...)` return UDAs in the 
> order they were declared in the source code, or is it 
> unspecified?

I think that is defined:

https://dlang.org/spec/attribute.html#uda

"If there are multiple UDAs in scope for a declaration, they are 
concatenated: "

and the example shows it in order.

It also says

"Whether the attributes are values or types is up to the user, 
and whether later attributes accumulate or override earlier ones 
is also up to how the user interprets them. "

Which implies it must be in order so you can make that 
determination.

It isn't as specific as I'd like, but it sure sounds like it must 
be in order to me.


More information about the Digitalmars-d-learn mailing list