This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: eval'ing a self-referential vector


Jim Blandy <jimb@red-bean.com> writes:

> > This eventually uses up all stack space.
> > I'm guessing scm_copy_tree is infinitely calling itself due to the
> > self-reference.
> 
> Sounds like a good guess.  Eval isn't expecting anything cyclic.

Exactly.

> > Question: why copy vectors when eval'ing them?
> 
> No reason.  scm_copy_tree should probably detect circularities.
> There's a treeish variant of the tortoise and hare algorithm we could
> use.

It isn't necessary to use the tortoise and hare since eval does right
in not expecting circular code.  What is wrong is that scm_copy_tree
copies vectors as well as pair structures.

Or, alternatively, if one wants copy-tree to copy vectors as well as
pair structures, then eval should not use scm_copy_tree.

Looking through the code, I see that copy-tree is only used in
situations where it is silly to copy the vector.

Looking in slib, I see that slib's version of copy-tree doesn't copy
vectors.

I just committed a change where I've removed the ability of copy-tree
to copy vectors, so the bug should be fixed now.

/mdj