GSoC 2016 - std.experimental.xml progress

Steven Schveighoffer via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon May 2 07:43:46 PDT 2016


On 5/2/16 8:25 AM, 9il wrote:
> On Monday, 2 May 2016 at 08:45:59 UTC, Lodovico Giaretta wrote:
>> Hi,
>>
>> Just a little update about my project...
>> After days of bugfixes, the first almost-high-level API (XMLCursor) is
>> now quite usable.
>> Now I can start working on other APIs (e.g. DOM) based on it.
>>
>> If you're interested you can find some usage examples in files
>> benchmark.d and test.d .
>> Any comment is highly appreciated.
>>
>> (If you missed it, the repo is
>> https://github.com/lodo1995/experimental.xml ).
>>
>> Thank you in advance.
>>
>> Lodovico Giaretta
>
> Hello Lodovico,
>
> Thank you for working on new xml. Please use size_t and sizediff_t
> instead of uint and int in your loops:
>
> for (auto i = 0; i < t.length; i++)
>
> should be replaced with
>
> foreach (size_t i; 0 .. t.length)

It's not obvious, but you identified 2 different things here.

auto i = 0 -> typeof(i) == int

size_t i = 0 -> typeof(i) == size_t

AND

use foreach instead of for loops for simple index traversal.

Note: foreach(i; 0 .. t.length) should correctly type i as size_t, there 
is no need to force it.

-Steve


More information about the Digitalmars-d-announce mailing list