www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Ordering of UDAs

reply Emmanuelle <VuLXn6DBW PPtUm7TvV6nsw.com> writes:
Hello! Does `__traits(getAttributes, ...)` return UDAs in the 
order they were declared in the source code, or is it unspecified?
Apr 22 2019
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
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.
Apr 22 2019
parent Emmanuelle <VuLXn6DBW PPtUm7TvV6nsw.com> writes:
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!
Apr 22 2019