March 12, 2014
On 3/11/14, 4:18 PM, Michel Fortin wrote:
> On 2014-03-11 20:28:58 +0000, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> said:
>
>> On 3/11/14, 11:23 AM, Jacob Carlborg wrote:
>>> [1] http://wiki.dlang.org/DIP43
>>> [2] https://github.com/jacob-carlborg/dmd/tree/d-objc
>>
>> Wow, this is fantastic. Congratulations!
>>
>> Upon a quick scan, the DIP seems tasteful and well put together. Let's
>> see how to merge this into dmd!
>
> Honestly, I don't think it's ready to be part of the official
> distribution (no memory management being the worse issue). But it
> doesn't mean it shouldn't be merged. You need to compile it with the
> D_OBJC define to get a compiler with Objective-C capabilities, which
> means that those capabilities don't necessarily need to be part of the
> official distribution even if the changes are merged.
>
> So merge ahead.
>
> Also, I'll be glad to participate in the review given I wrote most of
> that code.

Great. Jacob, what's your plan to take this forward? We're very interested in merging this as part of the official D compiler.

Andrei


March 12, 2014
On 11 Mar 2014 23:25, "Michel Fortin" <michel.fortin@michelf.ca> wrote:
>
> On 2014-03-11 22:43:58 +0000, "John Colvin" <
john.loughran.colvin@gmail.com> said:
>
>> To what extent will this be portable to ldc/gdc?
>
>
> The codegen elements in objc.c will need to be changed to bind to the
LLVM/GCC backend. Shouldn't be too hard, I guess.
>
> [1]: https://github.com/jacob-carlborg/dmd/blob/d-objc/src/objc.c
>

Oh no, not more work...


March 12, 2014
On Tuesday, 11 March 2014 at 21:48:45 UTC, Asman01 wrote:

> It's really awesome. Congratulations! If this DIP is actually approved will dmd have "native" integration/support to Objective-C language just like we can do with C? I'm not a Obj-C programmer but I like the idea.

Yes.

--
/Jacob Carlborg
March 12, 2014
On Tuesday, 11 March 2014 at 22:13:07 UTC, Paolo Invernizzi wrote:

> Thanks Jacob, great work!
>
> If someone is trying it like me, I don't know the proper way for doing that, but the compiler must be built with the DMD_OBJC define turned on.

Yes, D_OBJC. You need the corresponding changes for druntime [1] as well. It seems I haven't pushed the changes for 64bit, I'll do that tonight.

[1] https://github.com/jacob-carlborg/druntime/tree/d-objc

--
/Jacob Carlborg
March 12, 2014
On Wednesday, 12 March 2014 at 01:09:25 UTC, Walter Bright wrote:

> I'm glad to see this is building on the great groundwork you've already done.

Yes, absolutely. Michel has done most of the work, forgot to mention that. I'm just polishing now.

--
/Jacob Carlborg

March 12, 2014
On Tuesday, 11 March 2014 at 23:20:23 UTC, Michel Fortin wrote:

> The codegen elements in objc.c will need to be changed to bind to the LLVM/GCC backend. Shouldn't be too hard, I guess.

Yeah, since Objective-C uses the C calling convention it's mostly about outputting symbols and data to the object files.

--
/Jacob Carlborg
March 12, 2014
On Wednesday, 12 March 2014 at 01:45:38 UTC, Andrei Alexandrescu wrote:

> Great. Jacob, what's your plan to take this forward? We're very interested in merging this as part of the official D compiler.

In theory I could create a pull request tonight. It depends on what state we need the language support to be in. As I said exceptions are missing on 64bit. But on the other hand when support for C++ was introduced in D it had very limited support.

One idea is to merge the changes but wait with enabling the languages changes. The test machines could run the tests with the changes enabled.

--
/Jacob Carlborg
March 12, 2014
This is really awesome work. If you combined ARM support with Objective C support, it would mean you could write iOS programs in D without much frustration, and that would be a huge step forward. Objective C has a good runtime, but lacks templates and CTFE. Using CTFE for an iOS program could be very cool.

How do you plan to handle automatic reference counting? I imagine that's a hard part. When I was writing Objective C I remember having to write bridged casts so I could manually extend or limit object lifetime, but I never handled it from within a C library.
March 12, 2014
On 3/11/14, Jacob Carlborg <doob@me.com> wrote:
> I just wanted to let everyone know that I have implemented D/Objective-C for 64bit.

Excellent! One thing that's hard to implement right now in D is drag & drop support on OSX, at least when I tried to do it. The problem is I need to call ObjC functions or provide ObjC callbacks, so I end up having to create a C layer, compile that, and then link that to D. Actual support for interfacing with Objective C would be great.

Thanks for all the work to both you and Michel Fortin.
March 12, 2014
On 12 March 2014 07:10, Jacob Carlborg <doob@me.com> wrote:
> On Tuesday, 11 March 2014 at 23:20:23 UTC, Michel Fortin wrote:
>
>> The codegen elements in objc.c will need to be changed to bind to the LLVM/GCC backend. Shouldn't be too hard, I guess.
>
>
> Yeah, since Objective-C uses the C calling convention it's mostly about outputting symbols and data to the object files.
>

In what ABI may I ask?  Your choices are:
- Traditional (32bit) ABI without properties and Obj-C 2.0 additions
- Traditional (32bit) ABI with properties and Obj-C 2.0 additions
- Modern (64bit) ABI

That can be mixed in with either:
- GNU Runtime ABI
- NeXT Runtime ABI


Each combination being incompatible with each other subtly different ways...