feedback on simple modules?

23 views
Skip to first unread message

g

unread,
Feb 19, 2012, 8:10:56 PM2/19/12
to pyjaco - The Python to Javascript compiler
So,

I have spent some time and have modules compiling. I chose to use a
command line flag for pyjs.py and allow the previous functionality to
remain unchanged. You have to specify that you want pyjs to compile
as modules. I made sure that all tests still pass (on Windows) after
my modifications.

I did not see anywhere that pyjaco.append_module was being used for so
I started my changes here.

I have two tests that run under "tests/as_module/simple/". Once you
run the test you will see a file that ends with .run. That is the
javascript file that causes the js code to run. It uses the
$PY.run_module function I added to builtins.

I decided that it would be best to pass modules a reference to the
__builtins__ module. This will allow us to modify the pyjaco
namespace without needing to update any compiled code and it just
feels cleaner than reaching for a global __builtins__ object. The
code could still fallback to the global __builtins__ object if
wanted. I think it would be best if there was only one global
javascript object used for pyjaco in the future.

The run_module function also sets __name__ so that "if __name__ ==
'__main__'" initialization can be used.

Anyways, I was hoping for some feedback/thoughts.

Thanks,
Gordon

g

unread,
Feb 22, 2012, 4:03:39 PM2/22/12
to pyjaco - The Python to Javascript compiler
I forgot to link the repo: https://bitbucket.org/pendletongp/pyjaco

I have also added "import foo.bar" and "import foo.bar as x" support
now. The actual javascript implementation needs some work to behave
exactly like python, but it is currently functional. So that is good.
Reply all
Reply to author
Forward
0 new messages