[pypy-svn] r44606 - in pypy/dist/pypy/lang/scheme: . test

jlg at codespeak.net jlg at codespeak.net
Thu Jun 28 18:21:49 CEST 2007


Author: jlg
Date: Thu Jun 28 18:21:49 2007
New Revision: 44606

Modified:
   pypy/dist/pypy/lang/scheme/TODO.txt
   pypy/dist/pypy/lang/scheme/object.py
   pypy/dist/pypy/lang/scheme/test/test_eval.py
Log:
no arbitrary else statement for (if ...)

Modified: pypy/dist/pypy/lang/scheme/TODO.txt
==============================================================================
--- pypy/dist/pypy/lang/scheme/TODO.txt	(original)
+++ pypy/dist/pypy/lang/scheme/TODO.txt	Thu Jun 28 18:21:49 2007
@@ -9,9 +9,6 @@
 
 -+variables and execution context
 
-- symbols
-  - global dict for symbols _obarray_
-
 + there is need to distinct identifier from symbol
   (define var 11)
   (symbol? var) -> #f
@@ -23,6 +20,10 @@
 Do next
 -------
 
+- symbols (should be done with next point)
+  - global dict for symbols _obarray_
+- (quote <obj>) and '<obj>, not only symbols
+
 - functions
 - implement key funcions
   (apply, reduce, mapcar and so on)

Modified: pypy/dist/pypy/lang/scheme/object.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/object.py	(original)
+++ pypy/dist/pypy/lang/scheme/object.py	Thu Jun 28 18:21:49 2007
@@ -194,7 +194,10 @@
 def macro_if(ctx, lst):
     w_condition = lst.car
     w_then = lst.cdr.car
-    w_else = lst.cdr.cdr.car
+    if isinstance(lst.cdr.cdr, W_Nil):
+        w_else = W_Boolean(False)
+    else:
+        w_else = lst.cdr.cdr.car
 
     w_cond_val = w_condition.eval(ctx)
     if w_cond_val.to_boolean() is True:

Modified: pypy/dist/pypy/lang/scheme/test/test_eval.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/test/test_eval.py	(original)
+++ pypy/dist/pypy/lang/scheme/test/test_eval.py	Thu Jun 28 18:21:49 2007
@@ -93,6 +93,10 @@
     assert w_f.to_boolean() is False
     w_f = eval_expr(ctx, "(if 1 #f #t)")
     assert w_f.to_boolean() is False
+    w_f = eval_expr(ctx, "(if #t #t)")
+    assert w_f.to_boolean() is True
+    w_f = eval_expr(ctx, "(if #f #t)")
+    assert w_f.to_boolean() is False
 
 def test_if_evaluation():
     ctx = ExecutionContext()



More information about the Pypy-commit mailing list