def default(self, line): if line == "x" or line == "q": return self.do_exit(line) try: println(std.prn(compute(expandMacro(readAST(line))), 1)) except Exception as e: println(f"Error: {e}")
def _env(what=None, env=None, fout=None): s = std.prn((env or genv()).select(what)) spit(fout, s) if fout else println(s)
def prnLn(*xs): for a in xs: println(std.prn(a))
def _macros(fout=None): s = std.prn(CACHE) spit(fout, s) if fout else println(s)
def _reset(a, b): if std.isAtom(a): a.value = b return a ############################################################################## def _swap(a, f, *xs): p = [a.value, *xs] a.value = f(*p) return a.value ############################################################################## _intrinsics_ = { "macroexpand*": lambda a, e=None: println(std.prn(expandMacro(a, e or genv()))), "macros*": _macros, "env*": _env, "slice*": _slice, "throw*": lambda *xs: throwE("".join(xs)), "str*": lambda *xs: "".join([str(x) for x in xs]), "obj-type*": std.rtti, "gensym*": std.gensym, "is-eq?": std.isEQ, "is-some?": lambda o: not (o is None), "is-str?": lambda a: type(a) == str, "false?": lambda a: a is False, "true?": lambda a: a is True, "is-nil?": std.isNil, "is?": lambda a, b: a is b, "is-keyword?": std.isKeyword,