www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Check attribute against value

reply frame <frame86 live.com> writes:
I have an attribute scope:

```
 PublicApi {
   // ...
}
```

Querying with hasUDA! works as expected.
Later, I added a property to PublicApi:

```
struct PublicApi {
    bool exposeDetails;
}
```

And want to ask the compiler via getUDAs! about the boolean but 
this fails with:
```Error: type PublicApi has no value```

because I need to rewrite it to

```
 PublicApi() {
   // ...
}
```

... which works again.
But how do I check against such cases? And why does a struct not 
have a value here?
Apr 02
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
"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."

This doesn't explain it well, but you were adding types as attributes on 
to those symbols. Not struct instances.
Apr 02
parent frame <frame86 live.com> writes:
On Saturday, 3 April 2021 at 04:03:14 UTC, rikki cattermole wrote:

 This doesn't explain it well, but you were adding types as 
 attributes on to those symbols. Not struct instances.
omg - that's dumb - I was thinking the compiler whould be aware of that. So, I need to check for isType! first, thanks.
Apr 02