On Dec 8, 2008, at 7:45 PM, Mark Engelberg wrote:
I have an idea to try, but I'm not set up to build the java sources on my computer, so maybe someone else can run with it:
This looked very promising to me. For one thing, I remembered that the root of the big chain of LazyCons objects in memory (as displayed by the YourKit profiler) was "f".
I gave it a try, though, and it didn't solve the problem.I encourage someone else to try it as well. I'll continue to play with it later tonight.
My attempt is included below.
--Steve
Index: LazyCons.java
===================================================================
--- LazyCons.java (revision 1147)
+++ LazyCons.java (working copy)
@@ -15,11 +15,13 @@
final public class LazyCons extends ASeq{
final private static ISeq sentinel = new Cons(null, null);
IFn f;
+IFn r;
Object _first;
ISeq _rest;
-public LazyCons(IFn f){
+public LazyCons(IFn f, IFn r){
this.f = f;
+ this.r = r;
this._first = sentinel;
this._rest = sentinel;
}
@@ -43,6 +45,7 @@
{
throw new RuntimeException(ex);
}
+ f = null;
}
return _first;
}
@@ -57,13 +60,13 @@
//force sequential evaluation
if(_first == sentinel)
first();
- _rest = RT.seq(f.invoke(null));
+ _rest = RT.seq(r.invoke());
}
catch(Exception ex)
{
throw new RuntimeException(ex);
}
- f = null;
+ r = null;
}
return _rest;
}
Index: core.clj
===================================================================
--- core.clj (revision 1147)
+++ core.clj (working copy)
@@ -410,7 +410,7 @@
same node of the seq evaluates first/rest-expr once - the values
they yield are
cached." [first-expr & rest-expr]- (list 'new 'clojure.lang.LazyCons (list `fn (list [] first-expr) (list* [(gensym)] rest-expr)))) + (list 'new 'clojure.lang.LazyCons (list `fn [] first-expr) (list* `fn [] rest-expr)))
;(defmacro lazy-seq ; "Expands to code which produces a seq object whose first is the
smime.p7s
Description: S/MIME cryptographic signature
