DIP6: Attributes
Daniel Keep
daniel.keep.lists at gmail.com
Mon Aug 3 08:30:29 PDT 2009
grauzone wrote:
> Don wrote:
>> Ary Borenszweig wrote:
>>> http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP6
>>
>> This looks like a solution in search of a problem. What's the problem
>> being solved?
>
> Attaching additional data to types, that can't be specified otherwhere.
> This should help with metaprogramming-like stuff.
>
> For example serialization. How do you specify that a field shouldn't be
> part of the serialized data? Java has an extra keyword attribute like
> "transient" (comes from before attributes were introduced). C# uses what
> we call annotation in this thread. How would you do this in D?
struct Foo
{
int serialise_me, dont_serialise_me, or_me;
alias Tuple!("dont_serialise_me", "or_me") IgnoreForSerialisation;
}
Or, if you'd rather have a less hacky interface:
struct Foo
{
int serialise_me, dont_serialise_me, or_me;
mixin IgnoreForSerialisation!("dont_serialise_me", "or_me");
}
More information about the Digitalmars-d
mailing list