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

jlg at codespeak.net jlg at codespeak.net
Tue Jul 10 12:44:38 CEST 2007


Author: jlg
Date: Tue Jul 10 12:44:38 2007
New Revision: 44897

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:
list operation added

Modified: pypy/dist/pypy/lang/scheme/TODO.txt
==============================================================================
--- pypy/dist/pypy/lang/scheme/TODO.txt	(original)
+++ pypy/dist/pypy/lang/scheme/TODO.txt	Tue Jul 10 12:44:38 2007
@@ -1,21 +1,21 @@
 Do now
 ------
 
-- variables and execution context
-- list operations: cons car cdr list
-- comparison: = < > eq? eqv?
-- lambdas!
+- RPythonize (during EP sprint)
 
 Do next
 -------
 
-- symbols (should be done with next point)
+- definitions: let, let*, letrec
+
+- symbols vs identifier, which name is better
   - global dict for symbols _obarray_
-- (quote <obj>) and '<obj>, not only symbols
 
 - implement key funcions
   (apply, reduce, mapcar and so on)
 
+- comparison: < > eq? eqv?
+
 Do in some future
 -----------------
 
@@ -23,6 +23,7 @@
 
 - macros
 - proper tail-recursion
+  - mutulally recursive procedures (r5rs p.12)
 - delayed evaluation
 - continuations
 

Modified: pypy/dist/pypy/lang/scheme/object.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/object.py	(original)
+++ pypy/dist/pypy/lang/scheme/object.py	Tue Jul 10 12:44:38 2007
@@ -252,6 +252,10 @@
     def oper(self, x, y):
         return x * y
 
+class List(W_Procedure):
+    def procedure(self, ctx, lst):
+        return plst2lst(lst)
+
 class Define(W_Macro):
     def eval(self, ctx, lst):
         w_identifier = lst.car
@@ -344,6 +348,7 @@
         'cons': Cons,
         'car': Car,
         'cdr': Cdr,
+        'list': List,
             #comparisons
         '=': Equal,
             #macros

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	Tue Jul 10 12:44:38 2007
@@ -307,3 +307,14 @@
     assert isinstance(w_pair.cdr.car, W_Symbol)
     assert w_pair.cdr.car.to_string() == "y"
 
+def test_list():
+    ctx = ExecutionContext()
+    ctx.put("var", W_Fixnum(42))
+    w_lst = eval_expr(ctx, "(list 1 var (+ 2 1) 'a)")
+    assert isinstance(w_lst, W_Pair)
+    assert w_lst.car.to_number() == 1
+    assert w_lst.cdr.car.to_number() == 42
+    assert w_lst.cdr.cdr.car.to_number() == 3
+    assert w_lst.cdr.cdr.cdr.car.to_string() == "a"
+    assert isinstance(w_lst.cdr.cdr.cdr.cdr, W_Nil)
+



More information about the Pypy-commit mailing list