D/Objective-C, extern (Objective-C)

Jacob Carlborg doob at me.com
Mon Jun 24 03:04:01 PDT 2013


On 2013-06-23 23:02, bearophile wrote:

> Instead of:
> extern (Objective-C)
>
> Is it better to use a naming more D-idiomatic?
>
> extern (Objective_C)

As Simen said, we already have extern (C++). But I can absolutely change 
this if people wants to.

> Regarding this syntax:
>
> void insertItem(ObjcObject object, NSInteger value)
> [insertItemWithObjectValue:atIndex:];
>
> Is it possible and good to replace it with some UDA?

We could use an attribute. But I don't think it would be possible to use 
an UDA. Currently the compiler doesn't know anything about a particular 
UDA, all UDA's are treated the same. It it's either a built in attribute 
or an UDA. Doing something in between would be a lot harder.

> It seems contain some different things/syntax. I don't know how much
> Walter&Co will appreciate it.

I would say that it's very little new syntax, surprisingly. But 
semantically there's a lot of new stuff. But the core things are just 
the same as with extern (C), making D ABI compatible with another 
language, Objective-C. I think that this is mostly is a non-breaking 
change. All new keywords are prefix with two underscores, which is 
reserved by the compiler. A lot of stuff only apply for classes/methods 
declared as extern (Objective-C).

* extern (Objective-C) - I wouldn't really consider this new syntax

* [foo:bar:] - New syntax. Does not have to use this exact syntax but 
the functionality it provides is essential.

* Constructors in interfaces - Not really a new syntax. Just allows an 
existing syntax to be used in a new place.

* Foo.class - I guess this technically is new syntax. The only thing 
making this new syntax is the use of keyword. I we really don't want 
this we could rename it to __class or similar.

* __classext - Not implement yet, so that's up for discussion

* String literals - No new syntax. Just an implicit conversion added

* BOOL __selector(NSString) - New syntax. Kind of essential to have.

* Foo.protocolof - Not really a new syntax either. I don't think this is 
as essential as the other features.

* @IBOutlet and @IBAction - Not implemented. This could possibly be 
implemented as dummy UDA's.

* Blocks - Not implemented. I'm wondering if we could use the delegate 
keyword for this. If a delegate is marked as extern (Objective-C) it's a 
block. Or that might perhaps be confusing.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list