DMD 1.005 release

janderson askme at me.com
Fri Feb 9 22:50:39 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:
> janderson wrote:
>> Yauheni Akhotnikau wrote:
>>> On Thu, 08 Feb 2007 10:08:29 +0300, Walter Bright 
>>> <newshound at digitalmars.com> wrote:
>>>
> 
> Probably an easier way to go would be:
> 
> class A
> {
>   ...
>   int x;
>   B y;
>   int z;
> }
> 
> mixin(serialize!(A, "x=10, y"));

I'm not sure I'd need a mixin for this.

> 
> This way you leave to the compiler the task of parsing the class, and 
> you only deal with the annotations. If you prefer to not centralize them 
> (although for serialization it's probably better), you can write:
> 
> class A
> {
>   ...
>   mixin(serialize!(int, x, 10));
>   mixin(serialize!(B, y));
>   int z;
> }
> 
> Again, you let the compiler to the heavylifting and you limit your 
> annotation to the smallest notational unit.
> 
> 
> Andrei

Some good points, if your going for optimizing the compiler.  I was 
going for cleanest syntax.

-Joel



More information about the Digitalmars-d-announce mailing list