[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Objective-C 2.0
From: |
David Chisnall |
Subject: |
Re: Objective-C 2.0 |
Date: |
Wed, 2 Sep 2009 13:51:41 +0100 |
On 2 Sep 2009, at 12:17, Michael Thaler wrote:
Hi,
I am currently learning Objective-C on the Mac (using that book:-))
and I was
wondering if Objective-C 2.0 is available on Linux and if it can be
used for
gnustep development.
Yes, it is mostly available, but only if you compile with clang and
link against Étoilé's ObjectiveC2 framework[1].
If it is available is it ok to use it for gnustep?
Not for core GNUstep code, but certainly for your own code that you
want to use on top of GNUstep.
If it is not available, are
there any plans to support it?
Yes.
I think especially having a garbage collector
would be quite interesting. Personally I think having a GC would be a
sustantial advantage of gnustep over, e.g. Qt.
GNUstep has supported the Boehm GC for a while. Gregory has been
working on porting AutoZone too. Using GC is generally not a good
idea, because you will almost certainly find a framework that you want
to use which doesn't support it (and you will also find you can't port
your code to the iPhone). The combination of autorelease pools and
reference counting is usually enough.
If it is partly available, which features can (should) be used?
For maximum portability, none. The features which will work with
clang and ObjectiveC2.framework are:
- Fast enumeration (support may be missing in some GNUstep classes for
this; patches welcome)
- Declared properties.
- Zero-cost exceptions (requires all code to be compiled with DWARF
exception support).
- The new runtime APIs.
Non-fragile ivars are currently working with clang, but only with the
version of the GNU runtime on my hard disk. This situation should
also be fixed shortly.
I've no idea whether the Boehm GC works with clang-compiled code.
Clang has hooks for supporting GC in the runtime-specific code, which
are currently unimplemented for the GNU runtime. These will be added
when Gregory has finished porting AutoZone.
Are blocks
available (which seem to be a propertery Apple extension to C-like
languages)?
Yes, with the same requirements (compile with clang, link against
ObjectiveC2.framework). Blocks require you to compile your code with -
fblocks. You can test for their availability using the __has_feature
() pseudo-macro.
Is it possible to write applications that can be compiled on both
the Mac
using Cocoa and Linux using gnustep?
Yes, there are a great many examples of this. Remember that Objective-
C 2 is a relatively small set of extensions and Objective-C 1 was used
to write some very large applications and frameworks for two decades.
David