[pypy-svn] r24886 - pypy/dist/demo
auc at codespeak.net
auc at codespeak.net
Thu Mar 23 16:57:08 CET 2006
Author: auc
Date: Thu Mar 23 16:57:06 2006
New Revision: 24886
Modified:
pypy/dist/demo/producerconsumer.py
pypy/dist/demo/uthread.py
Log:
updated demos
Modified: pypy/dist/demo/producerconsumer.py
==============================================================================
--- pypy/dist/demo/producerconsumer.py (original)
+++ pypy/dist/demo/producerconsumer.py Thu Mar 23 16:57:06 2006
@@ -11,23 +11,23 @@
print "generate", n, limit
if n < limit:
return (n, generate(n + 1, limit))
- return (None, None)
+ return None
def sum(L, a):
print "sum", a
- head, Tail = newvar(), newvar()
- L == (head, Tail)
- if head != None:
- return sum(Tail, head + a)
- return a
+ Head, Tail = newvar(), newvar()
+ unify(L, (Head, Tail))
+ if Tail != None:
+ return sum(Tail, Head + a)
+ return a + Head
print "eager producer consummer"
print "before"
X = newvar()
S = newvar()
-S == uthread(sum, X, 0)
-X == uthread(generate, 0, 10)
+bind(S, uthread(sum, X, 0))
+unify(X, uthread(generate, 0, 10))
print "after"
-print S
-
+assert S == 45
+print S # needs a special treatment
Modified: pypy/dist/demo/uthread.py
==============================================================================
--- pypy/dist/demo/uthread.py (original)
+++ pypy/dist/demo/uthread.py Thu Mar 23 16:57:06 2006
@@ -10,11 +10,11 @@
X = newvar()
Y = newvar()
-Y == X
+bind(Y, X) # aliasing
def f():
print "starting"
- print is_unbound(X)
+ print is_free(X)
if Y:
print "ok"
return
@@ -22,7 +22,7 @@
return
def bind():
- X == 1
+ unify(X, 1)
uthread(f)
print "afterwards"
More information about the Pypy-commit
mailing list