Re: Idea For Attributes/Annotations

2009-03-10 Thread Daniel Keep
On the syntax for D, a few thoughts: In Python, the decorator expression must evaluate to a function, which is then called with the function being decorated. We could do something similar in D. Let's change the syntax to this for now: @(expr) decl Let's assume that expr must be a template. T

Re: Idea For Attributes/Annotations

2009-03-10 Thread Daniel Keep
For reference, Python has a concept called decorators. Take this function: > def trace(fn): > def __wrap(*pargs,**kwargs): > print 'IN %s' % fn.__name__ > r = fn(*pargs,**kwargs) > print 'OUT %s' % fn.__name__ > return r > > return __wrap And use it like

Re: Idea For Attributes/Annotations

2009-03-10 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:gp78hj$b2...@digitalmars.com... > - > // Something along these lines... > template generateEnum(char[] name, values...) > { >const char[] generateEnum = "enum "~name~"{"~/*values*/~"}"~ >"char[] enumToString("~name~" arg) { "~/*big s

Idea For Attributes/Annotations

2009-03-10 Thread Nick Sabalausky
I've previously voiced my desire for something similar to C#'s attributes (annotations in Java, IIRC), but that kind of got sidetracked into a discussion of command line parsers. I have another idea of a type of scenario where something like this would be very nice, and it also ties into the re