discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast enumeration


From: David Chisnall
Subject: Re: Fast enumeration
Date: Mon, 7 Feb 2011 18:32:04 +0000

GSFastEnumeration.h in base (added ages ago)

It include macros that exactly mimic the fast enumeration behaviour, so you get 
the speed, even without compiler support (the collection classes need to 
support it, but I think all of the GNUstep ones do now).

We could consider making this a public header.

David

On 7 Feb 2011, at 09:52, Fred Kiefer wrote:

> I remember reading a nice little Macro (or rather two?) that
> encapsulated all the foreach semantics for systems that don't support
> it. This was in David's Objective-C Phrasebook and perhaps David could
> donate that to some Foundation/base header file. That way we will just
> need to keep that header up to date with regards tot eh different
> compilers and anybody could use fast enumerations whenever they are
> supported on their computer without adopting the code.
> We might even think about using them ourselves in base and gui.
> 
> Fred
> 
> Am 04.02.2011 18:27, schrieb Nicola Pero:
>> 
>>>> If you refer to for(id x in y) syntax, I believe you just need to use
>>>> a compiler with objc2.0 support, as well as a sufficiently recent
>>>> runtime.
>>> 
>>> That, and support for the fast enumeration protocol in Base
>>> collections. This exists at least in base-1.20.1.
>>> 
>>> This doesn't actually resolve the question, though, it just restates it.
>>> 
>>> Which compilers support [this aspect of] Objective-C 2.0 outside of
>>> Apple's platforms? Neither gcc nor clang provide sufficiently
>>> comprehensive release notes to determine this sort of thing reliably.
>> 
>> GCC up to 4.5 does not support it.  GCC 4.6 (currently frozen, preparing
>> for release) does support it.
>> 
>> The GCC 4.6 release notes (http://gcc.gnu.org/gcc-4.6/changes.html)
>> contain a complete list of all the changes in the Objective-C
>> compiler in GCC 4.6.  In particular, they state:
>> 
>> "The Objective-C 2.0 fast enumeration syntax is supported in
>> Objective-C. This is currently not yet available in Objective-C++.
>> Fast enumeration requires support in the runtime, and such support has
>> been added to the GNU Objective-C runtime library
>> (shipped with GCC)."
>> 
>> I hope these release notes are clear and comprehensive enough ;-)
>> 
>>> How do I detect, at build time, which runtime I'm using, and precisely
>>> which version of what runtime has the necessary support? This is the
>>> sort of information one might expect to find on the ObjC2_FAQ wiki
>>> page, but one doesn't (and it's probably out of date anyway).
>>> 
>>> Basically, my choices are:
>>> * Test a rather large set of compiler, runtime and library versions
>>> together under a VM.
>>> * Hope that someone (i.e. David) imparts Secret Lore.
>>> * Continue to use slow enumeration extensively throughout Oolite for
>>> the next couple of years, except on 64-bit Mac OS X.
>> 
>> In the case of GCC, you can simply check for the macro __GNU_LIBOBJC__
>> which is defined only
>> by the GNU Objective-C runtime shipped with GCC 4.6 (and onwards) and by
>> no other runtime.
>> 
>> If that macro is #defined, you have fast enumeration support in the
>> compiler+runtime.  If not, you don't unless you're using
>> clang+libobjc2 I guess, which should be possible to check using another
>> macro.
>> 
>> Thanks
>> 
>> PS: Unfortunately, you are asking for a stable release, and GCC 4.6
>> hasn't been released yet, and you need gnustep-base
>> from trunk (soon to be released too) to use GCC 4.6.  In a couple of
>> months, you'll have it in stable releases :-)
> 
> 
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnustep


-- Sent from my STANTEC-ZEBRA




reply via email to

[Prev in Thread] Current Thread [Next in Thread]