[pypy-svn] r45341 - in pypy/dist/pypy/lang/scheme: . test
jlg at codespeak.net
jlg at codespeak.net
Thu Jul 26 13:15:52 CEST 2007
Author: jlg
Date: Thu Jul 26 13:15:51 2007
New Revision: 45341
Modified:
pypy/dist/pypy/lang/scheme/object.py
pypy/dist/pypy/lang/scheme/test/test_macro.py
Log:
tests more readable
Modified: pypy/dist/pypy/lang/scheme/object.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/object.py (original)
+++ pypy/dist/pypy/lang/scheme/object.py Thu Jul 26 13:15:51 2007
@@ -852,6 +852,7 @@
w_syntax_lst = w_syntax_lst.cdr
+ #closes template in syntactic enviroment at the point of definition
return W_Transformer(syntax_lst, ctx)
class SyntaxRule(object):
@@ -949,6 +950,8 @@
if isinstance(sexpr, W_Symbol):
w_sub = self.match_dict.get(sexpr.to_string(), None)
if w_sub is not None:
+ # Hygenic macros close their input forms in the syntactic
+ # enviroment at the point of use
return SyntacticClosure(ctx, w_sub)
return sexpr
@@ -963,7 +966,7 @@
#we have lexical scopes:
# 1. in which macro was defined - self.closure
# 2. in which macro is called - ctx
- # 3. in which macro is expanded - expand_ctx
+ # 3. in which macro is expanded, and can introduce new bindings - expand_ctx
expand_ctx = self.closure.copy()
expanded = self.expand(sexpr, ctx)
Modified: pypy/dist/pypy/lang/scheme/test/test_macro.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/test/test_macro.py (original)
+++ pypy/dist/pypy/lang/scheme/test/test_macro.py Thu Jul 26 13:15:51 2007
@@ -91,7 +91,6 @@
w_expr = parse("(foo bar)")[0]
w_expanded = w_transformer.expand(w_expr, ctx)
- #assert isinstance(w_expanded, W_Symbol)
assert w_expanded.to_string() == "bar"
w_transformer = eval_(ctx, """(syntax-rules ()
@@ -154,11 +153,11 @@
(loop (- counter 1)))))))
(loop count))))""")
- w_expr = parse("(_ 5 (set! counter (+ counter 1)))")[0]
+ w_expr = parse("(dotimes 5 (set! counter (+ counter 1)))")[0]
py.test.raises(UnboundVariable, w_transformer.expand_eval, w_expr, ctx)
eval_(ctx, "(define counter 0)")
- w_expr = parse("(_ 5 (set! counter (+ counter 1)))")[0]
+ w_expr = parse("(dotimes 5 (set! counter (+ counter 1)))")[0]
w_transformer.expand_eval(w_expr, ctx)
assert ctx.get("counter").to_number() == 5
More information about the Pypy-commit
mailing list