Range interface for std.serialization

Dicebot public at dicebot.lv
Thu Aug 22 07:52:40 PDT 2013


I'll focus on part I find crucial:

On Thursday, 22 August 2013 at 07:08:28 UTC, Jacob Carlborg wrote:
> The question is if a range should be treated as multiple 
> objects, and not a single object (which it really is). How 
> should it be serialized?
>
> * Something like an array, resulting in this XML:
>
> <array type="int" length="5" key="0" id="0">
>     <int key="0" id="1">1</int>
>     <int key="1" id="2">2</int>
>     <int key="2" id="3">3</int>
>     <int key="3" id="4">4</int>
>     <int key="4" id="5">5</int>
> </array>
>
> * Or like calling "serialize" multiple times, resulting in this 
> XML:
>
> <int key="0" id="0">1</int>
> <int key="1" id="1">2</int>
> <int key="2" id="2">3</int>
> <int key="3" id="3">4</int>
> <int key="4" id="4">5</int>

Is there a reasons arrays needs to be serialized as (1), not (2)? 
I'd expect any input-range compliant data to be serialized as (2) 
and lazy. That allows you to use deserializer as a pipe over some 
sort of network-based string feed to get a potentially infinite 
input range of deserialized objects.


More information about the Digitalmars-d mailing list