Thread overview
Ordering of UDAs
Apr 22, 2019
Emmanuelle
Apr 22, 2019
Adam D. Ruppe
Apr 22, 2019
Emmanuelle
April 22, 2019
Hello! Does `__traits(getAttributes, ...)` return UDAs in the order they were declared in the source code, or is it unspecified?

April 22, 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.
April 22, 2019
On Monday, 22 April 2019 at 19:32:27 UTC, Adam D. Ruppe wrote:
> 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.

Alright, that makes enough sense to me. Thank you!