User Defined Attributes

Tove tove at fransson.se
Wed Nov 14 03:18:27 PST 2012


On Wednesday, 14 November 2012 at 11:08:04 UTC, Leandro Lucarella 
wrote:
>
> Can you provide one concrete case where it makes sense NOT to 
> restrict UDAs to
> types and it's different from restricting exception to classes 
> derived from
> Exception?
>
> Thank you.

There was the example with Thrift...

   struct UserProfile {
         1: i32 uid,
         2: string name,
         3: string blurb
       }
       service UserStorage {
         void store(1: UserProfile user),
         UserProfile retrieve(1: i32 uid)
       }

You could use a user defined type for the struct... but for the 
members it would make sense to use the native type directly... 
and if you traverse the annotation in sequence rather than as 
standalone entities.. it's perfectly safe to use 1,2,3 as 
annotation...

i.e. first scan for the Thrift symbol, then scan for native typed 
int:s...



More information about the Digitalmars-d-announce mailing list