Proposal: user defined attributes

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Mar 21 11:32:02 PDT 2012


On 3/21/12 12:06 PM, Jacob Carlborg wrote:
> On 2012-03-21 16:11, Andrei Alexandrescu wrote:
> I think the liability here is that b needs to appear in two places, once
>> in the declaration proper and then in the NonSerialized part. (A
>> possible advantage is that sometimes it may be advantageous to keep all
>> symbols with a specific attribute in one place.) A possibility would be
>> to make the mixin expand to the field and the metadata at once.
>
> Yes, but that just looks ugly:
>
> class Foo
> {
> int a;
> mixin NonSerialized!(int, "b");
> }
>
> That's why it's so nice with attributes.

Well if the argument boils down to nice vs. ugly, as opposed to possible 
vs. impossible - it's quite a bit less compelling.

Andrei




More information about the Digitalmars-d mailing list