LRU cache for ~=

dsimcha dsimcha at yahoo.com
Mon Oct 19 12:47:17 PDT 2009


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> dsimcha wrote:
> > 2.  I don't understand how this solves the safety problem:
> >
> > // foo lives on the heap b/c we've idup'd it.
> > string foo = "This is only a test.".idup;
> > string bar = foo[0..4];
> > bar ~= " is _not ";
> > writeln(foo);  // prints "This is _not a test."
> >
> > Having access to the capacity in an LRU cache doesn't help if I understand it
> > correctly.
> Let me stress a point harder that I think I expressed poorly:
> The LRU cache stores the capacity of a given slice given _BOTH_ the
> slice's left and right bounds. If you later come with a slice that has
> only one correct bound, the LRU doesn't care about it. That's the safety
> tidbit.
> Andrei

I think I get it now, although it's very conservative.  One more question:  Is
this going to take the place of ArrayBuilder or be inaddition?  The LRU is a good
hack to preserve syntactic elegance and ease of use, but it's somewhat of a kludge
nonetheless and I'd ideally still like to see a real ArrayBuilder with full
array-like semantics if T[new] is definitely out.



More information about the Digitalmars-d mailing list