std.uuid: Ranges as parser input

Walter Bright newshound2 at digitalmars.com
Sun Jun 10 07:22:21 PDT 2012


On 6/10/2012 2:05 AM, Johannes Pfau wrote:
> Am Sat, 09 Jun 2012 23:06:25 -0700
>> Great! My initial suggestion is that the parsing routines should
>> accept input ranges, rather just arrays.
>>
>
> That could be done, but I currently keep the complete input string in
> the ParserException. That wouldn't be possible if the parser has to
> operate on an InputRange. It could work with a ForwardRange, but
> converting the Range back to a string wouldn't be very efficient. This
> would work best with some kind of BufferedRange/Stream concept.
>
> I'm just wondering whether it really makes sense to use ranges in this
> case. The text representation of UUIDs is usually exactly 36 characters
> long (for the simple parser it must be exactly 36 characters), so when
> using some kind of range interface and std.uuid it should be easy enough
> to read the UUID string into a stack buffer, then pass it to std.uuid.
>
> But if it's really desired, I can sure add an implementation using
> ForwardRanges.

I can see it wouldn't make sense for the simple parser, but for the more general 
one it may. You can also specialize the more general parser for arrays, so there 
won't be the overhead of making a copy.


More information about the Digitalmars-d mailing list