User Defined Attributes
Jacob Carlborg
doob at me.com
Tue Nov 6 11:38:47 PST 2012
On 2012-11-06 19:36, Walter Bright wrote:
> You're right, there is none. That's why using type names as attributes
> is more scalable and robust.
Then why allow it? Actually the more I think about it the more I think
you're right in that it's better to use a proper symbol or type name.
But I still don't like the syntax.
> I understand your desire to have attributes be implicitly declared, but
> I think that implicit declarations have historically been seductive, and
> much later were realized to be a mistake. This pattern has happened over
> and over :-)
Actually I don't. I was just trying to stay close to your
implementation. This is one of my proposals, from a one the threads you
linked to:
http://www.digitalmars.com/d/archives/digitalmars/D/Proposal_user_defined_attributes_161624.html#N161742
In that proposal you have to clearly define an attribute, like:
attribute class serializable { }
attribute class name
{
string fieldName;
}
@serializable class FooBar
{
@name("foo") int bar;
}
"serializable" and "name" would be symbols you can import have the same
name look up rules any other symbol.
--
/Jacob Carlborg
More information about the Digitalmars-d-announce
mailing list