[erlang-questions] Parse-transforming !! to a function call

Christian S <>
Sun Aug 12 03:09:56 CEST 2007


Objective-C looks like this:

  [[[object doStuffWith:foo and:bar] moreStuff] lastStuffUsing: baz];

Which is pretty close to something parsable in erlang. Using imagination.

The qlc module manages to use the LC syntax. How about you use nested
list syntax?
Imagine that objc:call is special like qlc:q and you implement this:

  Value = objc:call([[[Object, do_stuff(Foo, Bar)], more_stuff()],
last_stuff(Baz)]).

where do_stuff(Foo, Bar) and friends implements optional sugar such as:

  do_stuff(Foo, Bar) ->
    {'doStuffWith:and:', Foo, Bar}.

But just chaining like this is probably sugar enough and skips all of
parse transforms:

  objc:msgs([Object, do_stuff(Foo, Bar), more_stuff(), last_stuff(Baz)]).

where msgs sends messages like this:

  msgs([Object |Methods]) ->
    lists:foldl(fun(M, Object) -> objc:send(Object, M) end, Object, Methods).



2007/8/12, Joel Reymont <>:
>
> On Aug 12, 2007, at 12:41 AM, Christian S wrote:
>
> > I'm not all that crazy about the idea though. LispErlang would be
> > cooler. :)
>
> I'm looking for a neat way to express a synchronous call for ObjC/
> Cocoa. I'm not all that crazy about having (objc:send(objc:send
> (objc:send(...), ...), ...). I would rather have a shortcut!
>
> --
> http://wagerlabs.com
>
>
>
>
>
>



More information about the erlang-questions mailing list