Jeremie Pelletier Wrote:

> Justin Johansson wrote:
> > Jeremie Pelletier Wrote:
> > 
> >> He meant range structs as found in std.range and their array wrappers in 
> >> std.array.
> > 
> > Oh, okay.  Just groked src and looks like it is a D2 only thing.  Do you 
> > happen to know
> > what the derivation of the word "range" with respect to streams is?  I 
> > haven't come
> > across it before used in this context.
> 
> I don't know where the word range comes from, sorry. I see them as 
> streams because they work just the same, except for the different method 
> names (ie front/back and put instead of read and write respectively).
> 
> >> A range is D's version of streams, so for example a simple reader might 
> >> look like:
> >>
> >> void read(T)(in T range) if(isInputRange!T) {
> >>    while(!range.empty()) {
> >>            auto elem = range.front();
> >>            // process element
> >>            range.popFront();
> >>    }
> >> }
> >  
> >> I think you confuse ranges with slices. Ranges are simply an interface 
> >> for sequential or random data access. DOM trees and SAX callbacks are 
> >> different methods of parsing the xml, a range is a method of accessing 
> >> the data :)
> > 
> > Yes seems that way; my question apparently asked upon D1 knowledge only.
> > 
> > Re SAX, it easy enough to get James Clark's Expat 'C' parser happening with 
> > D.
> > That has an event-based API.  Perhaps all the std D library needs do is 
> > wrap this.
> > Whilst it's open source, dunno about the specific licensing issues though.
> > 
> > -- JJ
> > 
> 
> Isn't expat slower than libxml2's SAX? Anyways I'd rather code a SAX 
> module in D, if only to better know the internals of this method.

I don't know if it is slower or not .. just that it is reliable and deals with 
all subtleties of XML and
coming from James Clark (one cool dude), I suspect he probably got it right.  
Oh, and it written
in agnostic C.
It's easy enough though to write an XML parser and SAX like interface in an 
afternoon, 
maybe flow into the evening, and get 98% of the way there.
The other 2% will take you a month of Sundays.
That's the problem with XML is that it's deceptively simple.  Apparently Sun 
cannot even get it
right or just didn't bother.  Elliotte Rusty Harold's done a pretty good job 
with XOM; it's
held in very high regard in the Java/XML community.

As Michael Rynn (who started this thread) can vouch,
if you are looking for a model, std.xml (in D2) is *not* the role.

Cheers
Justin Johansson

Reply via email to