Is there a more succint syntax to call methods of javascript objects?

44 views
Skip to first unread message

Chanwoo Yoo

unread,
Dec 25, 2012, 8:35:59 PM12/25/12
to lispy...@googlegroups.com
Hello.

During my trial to use lispyscript, I found method call of javascript object is somewhat verbose.

If 'obj' is a javascript object, calling its method is easy: (obj.method)

However, if you want to call a method from newly created object, it needs to be written like this in lispyscript: (-> (new Sound) (.play))

I tried '(.play (new Sound))' but it didn't work because it translates to '(new Sound).play', not '(new Sound).play()'

It seems that '(.property obj)' is proper, but '(.method obj)' is not in lispyscript.

I tried ((new Sound).play) also, but it obviously didn't work.

I think '(-> (new Obj) (.method))' is somewhat verbose to call just a method and I surely miss something. Is there any other terse syntax for this in lispyscript?

Thanks in advance.


Santosh Rajan

unread,
Dec 25, 2012, 9:15:34 PM12/25/12
to lispy...@googlegroups.com
(.play (new Sound))  => (new Sound()).play;

The above yields a method.

Call the method by wrapping in an expression again.

((.play (new Sound)))  => (new Sound()).play();

Hope this helps.





--
You received this message because you are subscribed to the Google Groups "lispyscript" group.
To post to this group, send an email to lispy...@googlegroups.com.
To unsubscribe from this group, send email to lispyscript...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msg/lispyscript/-/J6HsHchHuZoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Santosh Rajan
@About.Me

Reply all
Reply to author
Forward
0 new messages