Early std.crypto

Steve Teale steve.teale at britseyeview.com
Tue Oct 25 23:28:52 PDT 2011


> 
> An easy test is that if the interface takes a T[] as input, consider a
> range instead. Ditto for output. If an interface takes a File as input,
> it's a red flag that something is wrong.

I have a question about ranges that occurred to me when I was composing a 
MySQL result set into a random access range.

To do that I have to provide the save capability defined by

R r1;
R r2 = r1.save;

Would it harm the use of ranges as elements of operation sequences if the 
type of the entity that got saved was not the same as the original range 
provider type. Something like:

R r1;
S r2 = r1.save;
r1.restore(r2);

For entities with a good deal of state, that implement a range, storing 
the whole state, and more significantly, restoring it, may be non-
trivial, but saving and restoring the state of the range may be quite a 
lightweight affair.

I'm also puzzled by the semantics of the random access range.

If I restrict myself to indexing into the range, then things are fine.

auto x = r[0];
x = r[10];
x = r[0];

But if I slip in a few popFront's, then presumably x = r[0] will give me 
a different result.

This just makes me slightly uneasy.

Steve


More information about the Digitalmars-d mailing list