Monday, 26 August 2013

@autorelease Pool and Loops (for, while, do) Syntax

@autorelease Pool and Loops (for, while, do) Syntax

clang allows the following loop syntax:
for (...) @autorelease { ... }
while (...) @autorelease { ... }
do @autorelease { ... } while (...);
I haven't found any documentation on that syntax so far (Apple doesn't use
this syntax in their guides, at least no in the guides introducing the
@autorelease construct), but is it reasonable to assume that the three
statement above are equivalent to the three statements below:
for (...) { @autorelease { ... } }
while (...) { @autorelease { ... } }
do { @autorelease { ... } } while (...);
Since that is what I would expect them to be (going by standard C syntax
rules), yet I'm not entirely sure if that's really the case. It could also
be some "special syntax", where the autorelease pool is not renewed for
every loop iteration.

No comments:

Post a Comment