DMD 1.005 release

Yauheni Akhotnikau eao197 at intervale.ru
Fri Feb 9 10:35:26 PST 2007


On Fri, 09 Feb 2007 20:13:14 +0300, janderson <askme at me.com> wrote:

> On the note of serialization I think you could be able to write  
> something like this:
>
> mixin(serialize(
> "
> 	class A
> 	{
> 		...
> 		serialize(10) int x; //(10 = default)
> 		serialize B y;
> 		int z; //Not serialized
> 	}
> "
> ));
>
> The serialize would pickup the serialize attributes and re-arrange the  
> code however it wanted (ie strip the serialize and put in a serialize  
> function)
>
> You probably could do it now, however it will be much easier when a  
> method of writing functions like serialize is invented.

This is not my case. It is necessary for me to use port existing framework  
to D and use existing DDL-files for serializabe types -- it is necessary  
for interoperability between existing C++ applications and future D  
applications.

There are the following steps in the current scheme for C++:
* a special macros must be used in declaration of serializable type (this  
macros hides some declarations of special methods);
* a DDL-file must be written with description of serializable types, its  
attributes and additional information;
* the DDL-file must be processed by special utility which produced file  
with implementation of serialization/deserialization method (those  
declarations are hid by the special macros);
* the generated file included into C++ file with serializable type  
implementation by #include.

DDL file is used to provide possibility to describe serialization of type  
 from different languages (C++, Java, D). So it cannot be replaced by some  
unique for D DSL.

Before D 1.005 I had want to generate module with template which contains  
serialization/deserialization code and use ordinal mixin expression to  
mixin that code in D class. D 1.005 makes things more simple -- the result  
of generation can be included into D class by new mixin expression. And if  
future versions make possible to include into D class DDL file itself --  
it will be great! Something like:

class Handshake : Serializable
{
   ... // declarations of attributes and methods.
   mixin( DDLProcessor( import( 'handshake.ddl' ) ) );
}

-- 
Regards,
Yauheni Akhotnikau



More information about the Digitalmars-d-announce mailing list