<div class="gmail_quote">On Thu, Oct 14, 2010 at 6:52 AM, Shin Fujishiro <span dir="ltr"><<a href="mailto:rsinfu@gmail.com">rsinfu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
So... how?<br>
<br>
To tell a truth, I've tried creating decorator ranges for character code<br>
conversion and zlib decompression, and both required internal caching.<br>
I think it's a limitation of the decorator design.<br>
<br>
Perhaps I'm missing something? Please tell us if you know a way to<br>
implement M:N decorators without caching!<br>
<div><div></div><div class="h5"><br></div></div></blockquote><div><br></div><div>By remembering where it's up to, and only popping items off the input when it's done with them. Maybe this is just another form of caching?</div>
<div><br></div><div>eg.</div><div>struct byByte<br>{</div><div> ushort[] data;</div><div> bool hi;</div><div> ubyte v;</div><div> this(ushort[] data) { this.data = data; }</div><div> void popFront()</div><div> {</div>
<div> v = hi ? (data.front >> 8) : (data.front & 0xFF);</div><div> hi = !hi;</div><div> if (!hi) data.popFront();</div><div> }</div><div> ubyte front() { return v; }</div><div> bool empty() { return data.empty; }<br>
}</div><div><br></div><div>I do understand this is not a perfect solution, and does not apply in some cases.</div></div>