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

Ryan Rawson <>
Sun Aug 12 03:57:58 CEST 2007


One weird thing is the "with" and "and" that you elide aren't really  
semantic sugar or ignorable. They are a meaningful part of the  
selector's name.  Destroying objective c to fit with erlang fills me  
with a special sad since the NS API is probably the best one I have  
ever seen. Also practically there are many selectors that start with  
the same prefix and differ only by the 2nd arguments. Your scheme  
would create some confusion there too.

-ryan


On Aug 11, 2007, at 6:09 PM, "Christian S" <> wrote:

> 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
>>
>>
>>
>>
>>
>>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list