std.d.lexer requirements

Christophe Travert travert at phare.normalesup.org
Fri Aug 3 01:21:27 PDT 2012


Jacob Carlborg , dans le message (digitalmars.D:174131), a écrit :
> static if(isNarrowString!R)
>      Unqual!(ElementEncodingType!R) first = range[0];
> else
>      dchar first = range.front;

I find it more comfortable to just use
first = range.front, with a range of char or ubyte.

This range does not have to be a string, it can be a something over a 
file, stream, socket. It can also be the result of an algorithm, because 
you *can* use algorithm on ranges of char, and it makes sense if you 
know what you are doing.

If Walter discovers the lexer does not work with a socket, a 
"file.byChunk.join", and has to do expensive utf-8 decoding for the 
lexer to work because it can only use range of dchar, and not range of 
char (except that it special-cased strings), he may not be happy.

It the range happens to be a string, I would use an adapter to make it 
appear like a range of char, not dchar, like the library likes to do. I 
think Andrei suggested that already.

-- 
Christophe


More information about the Digitalmars-d mailing list