www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Suggestions on D

reply Jonathan Small <Jonathan_member pathlink.com> writes:
Hi all,

I spent a couple of days last week working with D. I work for a game developer
and was looking at D from a game development perspective. I have to say I was
pretty impressed. Many of the design decisions are great, and exactly what is
needed to develop games software more quickly and simply. 

There were a couple of issues, which didn't seem resolved...

Serialization 
-------------

There doesn't seem to be one?

Of course you could write one and/or have objects that serialize implement a
ISerializable interface etc. You'd have to have an object handling the pointer
pickling/unpickling.

But many objects writing this code is just 'writing off the fields', so having
to implement an interface to make it work isn't very efficient.

So it would be great if
1) There was automatic serialization 
2) A standard way to override serialization (ISerializable + pickling in std
library)

Reflection
----------

I can't access fields of objects to implement an automatic serialization system.


Reflection is also great for being able to edit the contents of objects in game
editors. Would also be nice to have a IIntrospection standard interface to
provide a standard way of telling objects they are being altered.

I also don't seem to be able to construct an object from a name - again a
requirement for a serialization system.

Thanks for a great language, and heres hoping it will gain widespread
popularity. 

Regards,

Jonathan
Feb 18 2005
next sibling parent Chris Sauls <ibisbasenji gmail.com> writes:
Jonathan Small wrote:
 Serialization 
 -------------
 
 There doesn't seem to be one?
Agreed that it would be nice. You may want to visit dsource.org and look at the Concurrent and Mango projects (specifically Mango.). Mango is a complex library, mostly oriented toward server development, but many "branches" of the Mango "tree" are generally usable.
 Reflection
 ----------
 
 I can't access fields of objects to implement an automatic serialization
system.
Agreed again. And I /think/ (*emphasize think*) there as a reflection mechanism in the future plans for D. Probably not as a 1.0 feature, sadly. Meanwhile it isn't /too/ difficult to build in a simple string-based reflection mechanism, and you could even use a version(){} block to only compile the reflection code into your editor application. :)
 I also don't seem to be able to construct an object from a name - again a
 requirement for a serialization system.
Also supposed to be coming soon. I think the TypeInfo struct is supposed to get a pointer to the constructor eventually. Meanwhile, again, it isn't hard to set up. In this case, one method is to have a Manager class or module, with a .instanceOf(char[]) or .makeInstance(char[]) or the like. Then in classes that should be available, add a static constructor that registers the class name along with a factory method. Something like: class MyClass { static this() { ClassManager.register("MyClass", &(MyClass.makeInstance)); } static MyClass makeInstance() { return new MyClass; } } The obvious downside is you can only have "default" constructors, unless you provide a richer mechanism. -- Chris S
Feb 18 2005
prev sibling parent "Craig Black" <cblack ara.com> writes:
I agree reflection/serialization is an incredibly powerful feature that D 
lacks.  Reflection would is at the top of my list of feature requests.

-Craig 
Feb 18 2005