LRU cache for ~=

Leandro Lucarella llucax at gmail.com
Mon Oct 19 19:12:53 PDT 2009


Andrei Alexandrescu, el 19 de octubre a las 20:12 me escribiste:
> Bill Baxter wrote:
> >On Mon, Oct 19, 2009 at 5:07 PM, Andrei Alexandrescu
> ><SeeWebsiteForEmail at erdani.org> wrote:
> >>Rainer Deyke wrote:
> >>>Andrei Alexandrescu wrote:
> >>>>One surprising (but safe) behavior that remains with slices is this:
> >>>>
> >>>>void fun(int[] a) {
> >>>>  a[0] = 0;
> >>>>  a ~= 42;
> >>>>  a[0] = 42;
> >>>>}
> >>>>
> >>>>The caller may or may not see 42 in the first slot after the call.
> >>>Your definition of "safe" is clearly not aligned with mine.
> >>>
> >>>
> >>What's yours?
> >
> >Probably something like "safe from easy-to-write hard-to-debug
> >programming errors".
> >
> >I agree that it would stink if all these changes were made and *still*
> >one of the top gotchas with arrays/slices remained.  It also makes me
> >think slices and appending just don't belong together.  Appending to a
> >view ... just say no.
> 
> How to reconcile this viewpoint with that of people who find ~= all
> too darn convenient?

Use a proper array type, not a view (slice).

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
No recuerdo las flores, no conozco el viento
Aquí donde envejecen juntos presos y carceleros
Los días no pasan, el tiempo no pasa
Y vivimos contando el tiempo
Y moriremos contando el tiempo



More information about the Digitalmars-d mailing list