summaryrefslogtreecommitdiff
path: root/src/cli/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/runtime')
-rw-r--r--src/cli/runtime/FnSeq.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/cli/runtime/FnSeq.cs b/src/cli/runtime/FnSeq.cs
index 6225cc05..e98a3635 100644
--- a/src/cli/runtime/FnSeq.cs
+++ b/src/cli/runtime/FnSeq.cs
@@ -17,19 +17,30 @@ public class FnSeq : ISeq{
Object _first;
IFn restFn;
+volatile ISeq _rest;
public FnSeq(Object first, IFn restFn) {
this._first = first;
this.restFn = restFn;
-}
+ this._rest = this;
+ }
public Object first() {
return _first;
}
public ISeq rest() {
- return (ISeq) restFn.invoke();
-}
+ if(_rest != this)
+ return _rest;
+ lock(this){
+ if(_rest == this)
+ {
+ _rest = (ISeq) restFn.invoke();
+ restFn = null;
+ }
+ return _rest;
+ }
+ }
}
}