User Defined Attributes

dennis luehring dl.soluz at gmx.net
Tue Nov 6 09:00:33 PST 2012


Am 06.11.2012 17:50, schrieb Walter Bright:
> On 11/6/2012 8:42 AM, dennis luehring wrote:
>> Am 06.11.2012 16:18, schrieb Walter Bright:> On 11/6/2012 6:30 AM, dennis
>> luehring wrote:
>>  >   > Am 06.11.2012 14:14, schrieb Adam D. Ruppe:
>>  >   >> On Tuesday, 6 November 2012 at 07:55:51 UTC, Walter Bright wrote:
>>  >   >>> User Defined Attributes (UDA) are compile time expressions that
>>  >   >>> can be attached to a declaration.
>>  >   >>
>>  >   >> Hmmm, it didn't work on the most important place for my use case,
>>  >   >> function parameters:
>>  >   >>
>>  >   >> void a(["test"] int foo) {
>>  >   >>       pragma(msg, __traits(getAttributes, foo));
>>  >   >> }
>>  >   >
>>  >   > sad - but its still very young feature :)
>>  >   >
>>  >   > im using something like an description on my methods to describe parameter
>>  >   > "features" for an resource manager - something like "read", "write", "copy",
>>  >   > "read_write" etc.
>>  > But there's already out=write, read=all of them, read_write=ref, copy=not a ref
>>  > or an out.
>>
>> and now expand that to an higher level manager that use such information for
>> implementing(generating) runtime loading and locking strategies in a tree/graph
>> based environment - based on the parameters needs ... i've got something like
>> that in C++ using its own interface description language and an generator
>
> But D already has parameter attributes that cover those bases. What would UDAs
> add to that? (I know C++ is deficient in this, which is why IDL was invented,
> but I don't see what UDAs add to what D already provides - no IDL is needed for D).
>

just 2 questions:

1. what if my needs are beyond D?

for example my idl allows me to define a type based query source for 
parameters

CalculateStuff( TypeX [source="\\placement\(typeA|typeB|typeC)"] my_usage )

this defines the source of assignable objects to this method

2. what is the reason for stopping right before parameters? (except less 
coding on your side)




More information about the Digitalmars-d-announce mailing list