[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Embedded blocks...
From: |
David Chisnall |
Subject: |
Re: Embedded blocks... |
Date: |
Tue, 29 Oct 2019 13:43:29 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
On 29/10/2019 13:18, Ivan Vučica wrote:
Naive question: What’s the problem #ifdefing out the code that depends
on blocks when building on gcc?
Locally? Not much. It means that anyone using clang and a GCC-built
GNUstep will have some surprises, but they probably will anyway because
the GCC code will support the (very) old ABI and not be useable with
modern Objective-C anyway.
Globally? It means that we can't take advantage of things like ARC and
blocks usefully across GNUstep. Both have significant developer
productivity wins, as does Objective-C++ (which mostly works with recent
GCC, but still has some quite rough edges). If we have loads of
developers with ample time and aren't worried about the fact that it's
hard to recruit new Objective-C programmers when we force them to use a
decade-old version of the language, then that's not an issue either.
I haven't done much Objective-C recently, but the last time I did I
found that I could write about a quarter of the code in Objective-C++[1]
with ARC than I'd had to write in Objective-C with retain / release (and
got smaller and faster binaries). After that experience, there's no way
that I'd go back to writing the kind of code that GNUstep requires.
David
[1] I have a small set of helpers that improve interop:
- C++ wrappers for -hash, -compare: and -isEqual: that let me use
Objective-C objects in C++ collections.
- A get<> template that calls a -{foo}Value method based on the type
(e.g. get<int>(id x) -> [x intValue]). This allows me to write other
C++ templates that convert Objective-C objects to other types usefully.
- Wrappers for NSString and NSIndexSet that use the native range
accessors to implement C++ iterators, so these can be used with
range-based for loops (e.g. for (NSUInteger i : {some NSIndexSet}).
- An RIAA wrapper for posting KVO notifications. Posts the
will-change notification on construction and the did-change notification
on destruction, so I never accidentally fail to send one of the pair.
I also make heavy use of a number of Objective-C features that GCC
doesn't support:
- Generics (type erasing, but they catch simple compile-time type errors).
- Array and dictionary literals.
- Blocks
- ARC
- Private ivar definitions in the @implementation context.
All of these either improve my productivity, increase the quality of the
code, or both.
- Embedded blocks..., Gregory Casamento, 2019/10/26
- Re: Embedded blocks..., 陈北宗, 2019/10/26
- Re: Embedded blocks..., Gregory Casamento, 2019/10/26
- Re: Embedded blocks..., 陈北宗, 2019/10/26
- Re: Embedded blocks..., Gregory Casamento, 2019/10/27
- Message not available
- Re: Embedded blocks..., Gregory Casamento, 2019/10/27
- Re: Embedded blocks..., David Chisnall, 2019/10/29
- Re: Embedded blocks..., Ivan Vučica, 2019/10/29
- Re: Embedded blocks...,
David Chisnall <=
- Re: Embedded blocks..., Sergii Stoian, 2019/10/29
- Re: Embedded blocks..., Yavor Doganov, 2019/10/31
- Re: Embedded blocks..., address@hidden, 2019/10/31
- Re: Embedded blocks..., address@hidden, 2019/10/31