Skip navigation.
 
mlRe: File Extensions Problem
FROM : Graham Cox
DATE : Fri Aug 29 02:12:30 2008

On 29 Aug 2008, at 4:28 am, Ken Thomases wrote:

> On Aug 27, 2008, at 5:59 PM, R.L. Grigg wrote:
>

>> Hmm, I guess the wrinkle in this particular case is if the 
>> "contract" doesnt specify something that the programmer assumes to 
>> be safe to do (like enumerating backwards), how can you know how to 
>> implement your end?

>
> Enumerating NSArrays backwards is safe and supported by the 
> framework.  The earlier discussion had to do with mutating a 
> collection while enumerating, which is explicitly stated to be 
> unsafe.  Somebody (I forget who) claimed that mutating was "safe" 
> while enumerating backwards, but they were wrong.  In this case, 
> their wrongness was not based on things left unsaid in the contract, 
> but on violating things explicitly laid out in the contract.



Well, that was me. But I do see the error of my ways... I guess it was 
Michael Ash's comment that NSArray *could* change its storage half way 
through enumeration (if the collection were mutated) that woke me up. 
I suspect it would only do this if the collection dramatically changed 
in size but clearly that wouldn't be something to rely on. I checked 
my own code to make sure I wasn't following my own "advice" anywhere 
and turns out I've never done it without making a copy anyway.

cheers, Graham

Related mailsAuthorDate
mlFile Extensions Problem Adil Saleem Aug 22, 08:29
mlRe: File Extensions Problem Michael Dautermann Aug 22, 09:10
mlRe: File Extensions Problem Andrew Merenbach Aug 22, 09:22
mlRe: File Extensions Problem Graham Cox Aug 22, 09:28
mlRe: File Extensions Problem Phil Aug 22, 11:10
mlRe: File Extensions Problem Phil Aug 22, 11:27
mlRe: File Extensions Problem Graham Cox Aug 22, 12:23
mlRe: File Extensions Problem Phil Aug 22, 14:15
mlRe: File Extensions Problem Adam R. Maxwell Aug 22, 16:48
mlRe: File Extensions Problem Michael Ash Aug 22, 17:23
mlRe: File Extensions Problem Andrew Merenbach Aug 22, 17:39
mlRe: File Extensions Problem Sherm Pendley Aug 22, 18:27
mlRe: File Extensions Problem Charles Srstka Aug 22, 23:21
mlRe: File Extensions Problem Thomas Engelmeier Aug 23, 01:24
mlRe: File Extensions Problem Andrew Merenbach Aug 25, 06:21
mlRe: File Extensions Problem R.L. Grigg Aug 27, 20:50
mlRe: File Extensions Problem Ken Thomases Aug 27, 21:19
mlRe: File Extensions Problem Charles Srstka Aug 27, 23:05
mlRe: File Extensions Problem R.L. Grigg Aug 28, 00:59
mlRe: File Extensions Problem Phil Aug 28, 03:44
mlRe: File Extensions Problem R.L. Grigg Aug 28, 05:44
mlRe: File Extensions Problem Ingvar Nedrebo Aug 28, 17:25
mlRe: File Extensions Problem Michael Ash Aug 28, 17:52
mlRe: File Extensions Problem Ken Thomases Aug 28, 20:28
mlRe: File Extensions Problem Graham Cox Aug 29, 02:12
mlRe: File Extensions Problem Gerriet M. Denkman… Aug 29, 03:50
mlRe: File Extensions Problem Uli Kusterer Aug 29, 10:55
mlRe: File Extensions Problem Michael Ash Aug 29, 18:13