diff --git a/hy/compiler/modfaker.py b/hy/compiler/modfaker.py index dcbe72a..6d8a2fb 100644 --- a/hy/compiler/modfaker.py +++ b/hy/compiler/modfaker.py @@ -15,6 +15,10 @@ def _add_native_methods(mod): sys.stdout.flush() + def _read(*args): + return sys.stdin.readline() + + def _lex(*args): ret = [] for thing in args: @@ -124,7 +128,8 @@ def _add_native_methods(mod): "<=": _le, "!=": _ne, "eval": _eval, - "lex": _lex + "lex": _lex, + "read": _read, } for native in natives: diff --git a/hy/lang/builtins.py b/hy/lang/builtins.py index 8ddf1b2..dcc0e80 100644 --- a/hy/lang/builtins.py +++ b/hy/lang/builtins.py @@ -9,6 +9,14 @@ def _define(obj, lns): obj.namespace[args[0]] = args[1]() +def _loop(obj, lns): + fd = obj.get_invocation() + args = fd['args'] + while True: + for arg in args: + arg.eval(lns.clone()) + + def _fn(obj, lns): fd = obj.get_invocation() args = fd['args'] @@ -62,4 +70,5 @@ builtins = { "import": _import, "kwapply": _kwapply, "if": _if, + "loop": _loop }