erlang_js - implement function in Erlang

Miguel Morales therevoltingx@REDACTED
Wed Nov 17 22:56:49 CET 2010

Hi all,

I am interested in using the erlang_js module, however I am having
problems understanding if it can do what I want to do with it.
Basically, I'd like to implement javascript functions in Erlang, this
is basically to create a scripting system for my application.

Say I have a javascript string that looks like: "var x = MyFunction(1, 2);"

I would then like to implement MyFunction in Erlang somewhat like this:


MyFunction(Arg1, Arg2) ->
    io:fwrite("MyFunction called args: ~p, ~p~n", [Arg1, Arg2]).

I am using RabbitMQ and for the moment I simply send an MQ message to
a Java node that executes the javascript code.
The way Java does it is very nice, I just hava a MyClass class with
all my custom functions which can be called from evaluated javascript
The problem is keeping the code clean and the flow of things, I'd like
to integrate the scripting closer to the game logic.

Looking at the documentation, the closest
thing I see is the very last example where ejsLog is called inside the
javasript string.
However, this is implemented in C in spidermonkey.c.  Not sure if I'm
just missing something.  Any help would be appreciated.

~ Jeremiah:9:23-24
Android 2D MMORPG:,

More information about the erlang-questions mailing list