dmd 1.057 and 2.041 release

Fawzi Mohamed fmohamed at mac.com
Tue Mar 9 03:13:54 PST 2010


On 2010-03-09 09:09:51 +0100, Alexander Suhoverhov 
<alexander at suhoverhov.selfip.net> said:

> 
> 
> Steven Schveighoffer  at "Mon, 08 Mar 2010 15:23:51 -0500" wrote:
>  SS> On Mon, 08 Mar 2010 15:12:24 -0500, bearophile 
> <bearophileHUGS at lycos.com> wrote:
>  >> Steven Schveighoffer:
>  >>> Tell me how you would parse the following text serialization string for a
>  >>> string[]:
>  >>>
>  >>> hello world how are you
>  >>>
>  >>> What if it was a string[][]?
>  >>>
>  >>> Compare that to:
>  >>>
>  >>> [hello world, [how are, you]]
>  >>
>  >> You are missing something:
>  >>
>  >> ["hello world", ["how are", "you"]]
>  SS> For completely unambiguous, yes.  But still, I find often that 
> quotes are more noise than
>  SS> they are worth when just doing simple printouts.  What we  want is 
> the most useful
>  SS> default.
> 
> Commas are even more noise than than quotes. erlang:
> 
> [{app, "app1"}, {user, "user1"}, {score, 123456}, {date, 5000000}, 
> {misc, "foo"}]
> 
> But if you just drop commas:
> 
> [{app "app1"} {user "user1"} {score 123456} {date 5000000} {misc "foo"}]
> 
>  SS> -Steve

For a basic output one can discuss what is better, but in general, for 
a serialization approach I feel that the basic approach of the 
discussion is flawed.
A much better approach (that for example I did use in my serialization 
routines) is following the C++ philosophy that these details are 
handled by the target stream, not by the function sending the data.
For example I have implemented two serializers, one that serializes to 
json (with [,]""), and one that serializes to a binary format.
You write just one function, and then you can (even at runtime) change 
the details on the output, even from textual to binary, without 
changing anything in the serialization functions.
You don't want to write a different serialization function for each 
format, or go around hunting for all calls to add " to strings...

Now in my serialization routines I have a couple of design choices that 
maybe not everybody would share, but that I like:
- it is possible to get a meta information describing what will be 
serialized *before* serializing (this helps in dumping the meta 
information once at the beginning, and then serialize arrays with 
minimal overhead in binary mode, but makes serializing slightly more 
complex.
- it if possible (and not too difficult) to write serialization 
routines fully by hand, without any template, something very useful for 
objects that need special serialization. This method can also be fully 
customized.

< shameless bug promotion>
By the way as I have some horrible code due to 
http://d.puremagic.com/issues/show_bug.cgi?id=3472 and similar bugs in 
mixing interfaces and templates, I had written a much nicer version 
only to find out that it did not work...
</ shameless bug promotion>

I am transitioning the whole i/o in blip to a more abstract model based 
on simple delegates (sink/readers) that should make it easier to use it 
with either phobos or tango or any other source, but at the moment the 
input part still requires tango InputStreams (output part already 
transitioned).

Fawzi



More information about the Digitalmars-d-announce mailing list