This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Syntactic sugar to access arrays and hashes in Objective-C


Hi David,

Thanks for the reply, I've managed to find a solution for my needs in the end.
It turns out the Apple gcc compiler supports mixing C++ and Objective-C
in the same source file so I've been able to implement what I was looking
for using operator overloading - a much more flexible solution that doesn't
require the compiler to have knowledge of Apple's XCode core libraries.


I've attached the source, its a rather odd hybrid to say the least:

The documentation is here:
http://johnholdsworth.com/objcpp/html

I need to write the unit tests now.. I'm not sure its saved me any time in reality
but it was an interesting digression and hopefully it will be useful to somebody :)


Attachment: objcpp.h
Description: Binary data




Cheers,


John Holdsworth

On 8 Apr 2009, at 14:34, David Ayers wrote:

Am Samstag, den 21.03.2009, 11:59 +0100 schrieb John Holdsworth:

I was wondering if it would be a useful extension to Objective-C
expand the [] operator
to support array and hash references to NSArray and NSDictionary
classes directly to
greatly improve the readability of code:

I'm not an ObjC front end maintainer and have no authority but one issue
I would have with this feature with gcc proper is that the ObjC front
end would have to learn about the semantics of "NSArray" and
"NSDictionary" which are actually not part of the language but part of
an external library.


Now gcc already supports the -fconstant-string-class option as one way
to embed knowledge about an external library into an executable. But I
would like adding options with all these semantics from a foreign
library into the language implementation.


Maybe this could be done more elegantly with plugin infrastructure that
that es being currently added: http://gcc.gnu.org/wiki/plugins


Cheers,
David




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]