User attributes (was Proposal on improvement to deprecated)
Jacob Carlborg
doob at me.com
Mon Oct 3 12:42:56 PDT 2011
On 2011-10-03 20:22, Piotr Szturmaj wrote:
> Aleksandar Ružičić wrote:
>> What about using an attribute for that?
>
> Looks like a good use case for user defined attributes (I need to write
> DIP on that).
>
> There are of course many other possible use cases like Object/Relational
> Mapping, RPC/Remoting, debugger visualization overrides, hints for the
> GC, etc.
>
> User defined attributes provide a powerful way to extend language
> without constantly upgrading the compiler (and avoiding "too many
> features" in it).
>
> I would love to hear any opinions about general idea of user defined
> attributes in D, not necessarily this particular syntax as it is only
> my loud thinking, though it should show what the whole thing is about.
I would love this see this as well. I think it needs to be accessible at
runtime too. It should be possible to get the attributes of a class
through a base class reference and it should return the attributes of
the runtime type.
I would like to have something similar as this possible as well:
class Foo
{
@get_set int x;
}
Would insert a getter and setter for "x" like this:
class Foo
{
int x_;
int x () { return x_; }
int x (int x) { return x_ = x; }
}
An attribute should be able to insert something else instead of the
symbol it applies to, or nothing at all.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list