pure, safe and generalized attributes

bearophile bearophileHUGS at lycos.com
Fri Apr 4 11:57:58 PDT 2008


Leandro Lucarella:
> Or something simpler, like Python's decorators:
> @KilroyWasHere
> int func(param p1)
> {
>     ...
> }

Do you mean to copy just the syntax? Because Python decorator semantics is quite different, they are a way to feed a function/method to one of more metafunctions :-)

So this:

@foo
int func(param p1) {}

means something like:

func = foo(func)

And there are more complex usages, stacking more than one decorators, giving them arguments, etc.

Bye,
bearophile



More information about the Digitalmars-d mailing list