late night hacks

This commit is contained in:
Paul Tagliamonte 2012-12-17 01:22:37 -05:00
parent 0081d4fdfc
commit 14e716f05f
3 changed files with 12 additions and 5 deletions

View File

@ -59,10 +59,14 @@ def forge_module(name, fpath, forest):
_add_native_methods(mod)
def shim():
ns = globals()
for tree in _hy_forest:
tree.set_namespace(ns)
for tree in _hy_forest:
tree.set_namespace(globals())
tree()
mod.__dict__['_hy_self'] = mod
eval(shim.__code__, mod.__dict__)
return mod

View File

@ -1,4 +1,5 @@
#
import sys
def _define(obj):
@ -30,8 +31,10 @@ def _import(obj):
mods = args[0]
for module in mods:
basename = module.split(".", 1)[0]
mod = __import__(module)
obj.namespace[module] = mod
sys.modules[module] = mod
ns[basename] = mod
builtins = {

View File

@ -1,9 +1,9 @@
; vim: tabstop=2 expandtab shiftwidth=2 softtabstop=2 filetype=lisp
(import ["sys"])
(import ["sys"
"os.path"])
(def square (fn [x]
(* x x)))
(print (square 2))
(print sys.argv)
(print os.path)