[erlang-questions] Obj-C bridge

Christian S <>
Sun Aug 12 15:55:48 CEST 2007

2007/8/12, Joel Reymont <>:
> On Aug 12, 2007, at 2:09 AM, Christian S wrote:
> > Objective-C looks like this:
> >   [[[object doStuffWith:foo and:bar] moreStuff] lastStuffUsing: baz];
> I'm in favor of modifying the parser to add the !! notation (aliased
> to !) and then doing

Are you going to make this objc-bridge open source? Because modifying
the scanner
and parser to make the syntax parsable will make it difficult to begin
using the code, it needing special compilation methods, which might be
more of a nuisance than the benefit of the syntax itself.

> A = object !! [{dostuffWith, foo}, {and, bar}],
> B = A !! [moreStuff],
> C = B !! [{lastStuffUsing, baz}]
> What do you think?

It displays its sequential order very clearly, but dont you think it
is a bit verbose?

The reason I used do_stuff(Foo, Bar) for constructing something like
{'doStuffWith:and:', Foo, Bar} is that the more intelligent editors
can perform tab completion and pop up documentation for functions.
Dialyzer will perhaps be more practical too, and guards on the
do_stuff arguments can perform sanity checks. But the quick hack can
still spell out a selector name directly in the code (shell!) and
refactor it later.

Another idea, similar in verbosity to your bang-bang approach.
A = {Object, 'doStuffWith:and:', Foo, Bar},
B = {A, 'moreStuff'},
C = {B, 'lastStuffUsing:', Baz},
%% Or objc:eval(Port, C) where Port is one of several separated objc
ports, or just
%% something to hang preregistered shortcut atom names on for
frequently used objects.

You would also get a way to get a bunch of methods happen atomically.
Now that we make such a big deal of concurrency in erlang. :)

The best approach is probably to write some code in erlang for the
various syntax suggestions, get a feel for how they're to work with
and how well they read. Then implement
the one you like best.

> I also think that I would rather add the Obj-C runtime functions as
> Erlang BIFs than to use the FFI. I definitely want the bridge to run
> inside the Erlang VM so I'm still don't know how to best combine the
> Erlang runtime with that of Obj-C. Cocoa wants its own run loop which
> could be a problem.

Conventional wisdom is to do this later, if at all, and start out with
an external port process since it is easier and find out if it would
be a good idea with closer interaction. Myself, I tend to always
underestimate the speed of computers with a factor of 100.

Memo to self: I need to look into how one gives linked in drivers
threads of their own and how to communicate with the erlang runtime.

More information about the erlang-questions mailing list