You can put the attribute on the function. There are a couple of go libraries that use struct tags in a similar way. Such as code.google.com/p/gorest On 6 Nov 2012 15:15, "Adam D. Ruppe" <destructiona...@gmail.com> wrote:
> 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)); > } > > test.d(1): Error: basic type expected, not [ > test.d(1): Error: found 'int' when expecting ')' > test.d(1): Error: semicolon expected following function declaration > test.d(1): Error: no identifier for declarator foo > test.d(1): Error: semicolon expected, not ')' > test.d(1): Error: Declaration expected, not ')' > > > > The reason why this is important to me is I have a nice automatic form > builder given a function signature. I'd like to add things like hints about > the params that my existing code can take a look at. > > > (a problem that might remain is being able to reference the parameters > outside... I use a ParameterTypeTuple and .stringof right now but that > probably won't work for getAttributes. But we can always solve that later.) >