<div class="gmail_quote">On Tue, Oct 12, 2010 at 7:18 PM, Masahiro Nakagawa <span dir="ltr"><<a href="mailto:repeatedly@gmail.com">repeatedly@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Yes, your range doesn't need allocation.</div>
However, users eventually need to store the result returned from the range to the buffer allocated by themselves.<br>
How to use the encoded / decoded result?<div class="im"><br></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">"copy(encode(data), buffer)" seems to be equivalent to 'encode(data, buffer)'.<br>
<br>
Sorry, I don't almost see the merit of your proposal.<br>
Base64 is simple(ubyte[] -encode-> char[], char[] -decode-> ubyte[]).<br>
Your range seems to be over-generalization to Base64...<br>
<br>
P.S.<br>
encode(InputRange, OutputRange) becomes a new function candidate for no allocation.<br>
Of course, decode too. These are inspired by your range.<br><font color="#888888">
<br>
<br>
Masahiro</font><div><div></div><div class="h5"><br></div></div></blockquote><div>I guess it's the difference between an function that works on ranges and a range that adapts data. I assumed the latter would be the best choice for linear encoding/decoding of a data stream. I don't think there's a precedent to follow on this yet.</div>
<div>The main use case that won't work with this design is when the output is done by a function, not another output range.</div><div><br></div><div>eg.</div><div>sendOverNetwork(base64Encode(lazyReadFromFile(Filename)));</div>
<div><br></div><div>I don't see how this can be done without allocation when the output method does not provide an output range.</div><div><br></div><div>The data can also be piped through other conversion or encoding ranges.</div>
<div>eg.</div><div>auto uuencoded = array(uuencode(base64Decode(inputdata)));</div><div><br></div><div>auto encdata = base64Encode("1,2,3,4");</div><div>foreach(n; map!(to!int)(splitter(base64Decode(encdata), ',')))<br>
{</div><div> // do something with n<br>}</div><div><br></div><div>I guess what I'm saying is that data doesn't always end up in an output range, or in a newly allocated array.</div><div>Maybe this is way more general than is needed, but I see it fitting the other range designs in phobos much more closely.</div>
<div><br></div><div>Daniel.</div></div>