stdx.data.json needs a layer on top

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 25 00:47:14 PDT 2015


Am 24.06.2015 um 23:50 schrieb Martin Nowak:
> On 06/23/2015 04:06 PM, Sönke Ludwig wrote:
>>
>> Do you, or anyone else, have further ideas for higher level
>> functionality, or any concrete examples in other standard libraries?
>
> Allowing to lazily foreach over elements would be nice.
>
> foreach (elem; nodes.readArray)
> {
>      // each elem would be a bounded node stream (range)
>      foreach (key, value; elem.readObject)
>      {
>      }
> }
>

An initial version of readArray is up for discussion:
https://github.com/s-ludwig/std_data_json/blob/3efc0600b4f8598dd6ccf897d6140d3351b5ee84/source/stdx/data/json/parser.d#L955

Unfortunately it is @system, because the reference to the input range 
gets escaped. The "VR" struct also has to be non-copyable to avoid its 
"depth" field to get out of sync when it gets copied around.


More information about the Digitalmars-d mailing list