LRU cache for ~=

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Oct 19 19:44:18 PDT 2009


Rainer Deyke wrote:
> Denis Koroskin wrote:
>> On Tue, 20 Oct 2009 03:00:57 +0400, Rainer Deyke <rainerd at eldwood.com>
>> 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.
>> Safe as in SafeD (i.e. no memory corruption) :)
> 
> If the caller wasn't expecting the array to be modified, then that's a
> textbook case of memory corruption.

[citation needed]

Andrei



More information about the Digitalmars-d mailing list