From 132b8432e8222a815520a918ed8807053c78601c Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Sun, 31 Jan 2021 17:24:40 -0800 Subject: [PATCH] fix: compute arguments to >> in correct order. --- trans/javascript.str | 7 +++++-- trans/python.str | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/trans/javascript.str b/trans/javascript.str index 10a3472..398c29e 100644 --- a/trans/javascript.str +++ b/trans/javascript.str @@ -8,7 +8,10 @@ signature rules js: TopLevel(x) -> $[const Stdio = { receives: v => { process.stdout.write(String(v)); return Stdio; }, - forwards: v => { process.stdout.write(String(v)); return v; } + } + function forwards(data, strm) { + strm.receives(data); + return data; } [x]] @@ -16,7 +19,7 @@ rules js: Int(x) -> x js: Sum(x) -> $[[x].reduce((v,w) => v+w)] js: Receives(x, y) -> $[[x].receives([y])] - js: Enters(x, y) -> $[[y].forwards([x])] + js: Enters(x, y) -> $[forwards([x],[y])] jslist: x -> $<[<x>]> diff --git a/trans/python.str b/trans/python.str index 1681468..85b845b 100644 --- a/trans/python.str +++ b/trans/python.str @@ -12,9 +12,9 @@ rules def receives(self, v): print(v, file=sys.stdout, end='') return self - def forwards(self, v): - self.receives(v) - return v + def forwards(data,strm): + strm.receives(data) + return data Stdio = StdioC() [x]] @@ -22,7 +22,7 @@ rules py: Int(x) -> x py: Sum(x) -> $[sum([x])] py: Receives(x, y) -> $[[x].receives([y])] - py: Enters(x, y) -> $[[y].forwards([x])] + py: Enters(x, y) -> $[forwards([x],[y])] pylist: x -> $<[<x>]>