DMD 1.005 release
Yauheni Akhotnikau
eao197 at intervale.ru
Fri Feb 9 22:54:36 PST 2007
On Sat, 10 Feb 2007 03:14:48 +0300, Andrei Alexandrescu (See Website For
Email) <SeeWebsiteForEmail at erdani.org> wrote:
> Probably an easier way to go would be:
>
> class A
> {
> ...
> int x;
> B y;
> int z;
> }
>
> mixin(serialize!(A, "x=10, y"));
>
> This way you leave to the compiler the task of parsing the class, and
> you only deal with the annotations.
Yes. And this has yet another advantage -- it may be necessary to support
several servialization methods at one time. For example, home-made
serialization method and ASN.1 BER serialization:
// home-made serialization.
mixin( serialize!(A, "x=10, y"));
// ASN.1 BER.
mixin( asn1ber_serialize!(A, "x,tag=0x1020,optional=10", "y,tag=0x1139"));
--
Regards,
Yauheni Akhotnikau
More information about the Digitalmars-d-announce
mailing list