D/Objective-C Preliminary Design
Robert Clipsham
robert at octarineparrot.com
Thu Nov 4 12:09:27 PDT 2010
On 04/11/10 00:51, Walter Bright wrote:
> Michel Fortin wrote:
>> You heard that right: someone is considering writing Cocoa programs
>> because of D!
>
> That's great news!
>
>> I think we should try to attract Cocoa programmers (and would-be Cocoa
>> programmers) by offering them the strengths of D. What are those
>> strengths? Some are things you probably take for given (overloading),
>> others are design by contract, generic programming, nested classes,
>> mixins, integrated unittests and documentation, memory safety, a
>> race-free threading model, did I miss anything? All those good things
>> aren't available in Objective-C and thus can't be used with Cocoa. I
>> want to make those them available to Cocoa programmers. And for this,
>> I need them to work with the Objective-C object model. By making
>> Objective-C objects bind to D semantics, all those feature will "just
>> work" with Cocoa with minimal changes to the frontend (and well
>> written bindings).
>
>
> I don't know O-C. I've never written a line of it. So I'm shooting in
> the dark about the best way to attach it to D.
It's an odd little language, took me forever to pick up even the basics,
unlike D/C++/Java/C# etc, everything seems so backwards to me. The
following might help clarify somewhat (although it may be incorrect, I'm
sure someone will correct me if it is - I am but an amateur when it
comes to ObjC).
ObjC has (optional) named parameters, when it does they become part of
the method name, eg:
[someObj foobar];
[someObj foobar withString:@"bar"];
is effectively equivalent to (in pseudo-D):
someObj.foobar();
// Where pseudo-D has named parameters, and uses the same method name
// as the Obj-C code
someObj.foobar:withString:(withString="bar");
> I agree with all your goals.
>
> One possibility: simply adopt O-C syntax.
I personally would be against this, I'm sure there are a lot of people
who wouldn't be though. D has a really nice, simple syntax - the only
syntactic errors are purely my finger missing the ; key etc... I still
struggle with Obj-C syntax, heck, you can get Obj-C syntax wrong and
it'll still compile with no warnings, then you're left wondering why
your app is segfaulting.
--
Robert
http://octarineparrot.com/
More information about the Digitalmars-d
mailing list