mulle-objc: present and absent language features
Continued from mulle_objc: inheriting methods from protocols of the mulle_objc series.
Updated: 7. November 2016
Objective-C is now a hybrid of many languages. The timeline being approximately this:
ObjC 1.0: C plus Smalltalk
<- appeasement of the Java Noobs
ObjC++
ObjC 2.0
<- usurpation by the C++ Flagellants
mulle_objc is supposed to put the basis of Objective-C back to ObjC 1.0 and cherrypick improvements from the later versions.
Here is a list of what’s going on and what will be going on and what will not happen. Taking most of the terminology from:
The separation between Compiler, Runtime and Language is of course a bit arbitrary.
Language
Topic | State |
---|---|
BOOL | supported: but it is an int . If you really need to use bool use _Bool . |
@”string” | supported |
@1, @(), … | planned: what is known as “Literals” |
NSArray *foo; foo[ 1] | not planned: [^1] what is known as “Subscripting” |
@defs() | supported |
@encode() | supported: 90% the same as the Apple runtime |
@package | never: will produce an error |
@property | supported |
@autoreleasepool | supported |
@synchronized() | not planned |
@compatibility_alias | unknown |
@try @catch | supported |
for ( i in x) | supported: what is known as “Fast Enumeration” |
nonatomic | supported |
atomic nonatomic | not planned |
atomic as default | never |
instancetype | supported |
generics | never |
nullable | not planned: will produce an error [^2] |
nonnullable | supported |
property dot syntax | not planned: [^1] |
Protocol | never: you have to use PROTOCOL instead of Protocol * |
weak, strong | never |
__bridge |
will be a nop #define (also __bridge_retained , __bridge_transfer ) |
__unsafe_unretained |
could be a nop #define (_autoreleasing ) |
Compiler
Topic | State |
---|---|
Default synthesis | supported |
ARC | never, but look below for AAM |
Exceptions | supported |
static NSStrings | supported |
variadic arguments (:…) | supported, but not compatible to <stdarg.h> |
Runtime
Topic | State |
---|---|
Non-fragile ivars | never |
^blocks | not planned: [^3] |
Fast enumeration | supported |
ObjectiveC++ | never: But the mulle-objc instance memory layout should be this->__vtab compatible to have dual facing objects. |
Class extensions | never: at least when you want to add instance variables |
Modules | not planned |
Other “planned” features
For some of the “supported” features like protocol inheritance, please read the complete series.
Topic | State |
---|---|
AAM | supported: a much simpler successor to ARC called “Always Autoreleased Mode” |
Generated parameter compliancy asserts | planned: with a special compiler option each object parameter of a method will be checked with NSParameterAssert for class compliancy. Here nonnullable will be useful. |
Method chaining | technically supported: you can search the runtime to supply you with the overridden methods. But it’s slow. |
[^1] : This is basically operator overloading, which is un-C like.
[^2] : Superflous keyword, ObjC is by design nullable. It only makes sense to adorn non-nullable parameters.
[^3] : GCD is a Apple technology, that really needs kernel support to work well. lambdas are not a part of C11. Generally I find blocks unconvincing. It might be an idea to make NSInvocation
s out of block syntax ?
Glossary
Wording | Meaning |
---|---|
supported | should work already |
will be supported | must work with the first release |
not supported | might just accidentally work |
planned | may not be in the first release |
unknown | neither “planned” not “not planned” |
not planned | never say never, but this probably won’t happen |
never | sometimes you have to say never :) |
Continue to mulle-objc: the trouble with property
Post a comment
All comments are held for moderation; basic HTML formatting accepted.