gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Can't Pretty-print?


From: Camm Maguire
Subject: Re: [Gcl-devel] Can't Pretty-print?
Date: 15 Feb 2002 11:49:10 -0500

Greetings!

Martin Rubey <address@hidden> writes:

> I'm sorry, but I do not quite understand your reply. What is the
> pretty-print stack?
> 

Gcl has an internal stack it uses for printing indentation.  By
default, it is 128 elements long.

> When I debug the code, everything works fine until I reach the push the
> sixth time. Then, when I ask for new-cartesian, I get the error message.
> 

Right.  I can tell you where it happens in the C source too if you are
interested. 

> Note that
> 
> (cartesian (list '((a b) (c)) '(((a) (b)) ((c) d))))
> 
> works all right. I would expect that gcl doesn't care whether the elements

Don't know so much about lisp, but "pretty-printing" this expression
takes fewer stack entries, i.e. it is not as nested in some sense.
You can probably find an example to overflow the stack no matter how
big it is.  Maybe it should be dynamically allocated.  But then there
are many places in gcl where this should be the case, AFAICT.

> of the sets passed to cartesian are atoms or elements...
> 
> (I'm a newbie, please be patient with me)
> 
> Redefining Q_SIZE would mean recompiling, wouldn't it?
> 

Yes.

Take care,

> Martin
> 
> > > (cartesian (list '((a b) (c)) '( ((a) (b)) ((c) (d)))))
> > >
> > > (defun cartesian (sets)
> > >  "Returns the Cartesian product of a list of sets
> > >   Example:
> > >        (CARTESIAN '((A B) (C D) (E F)))
> > >          ;=> ((B C F) (B C E) (B D F) (B D E) (A C F) (A C E) (A D F) (A D
> > > E))
> > >   Non-recursive version.
> > >   "
> > >  (let ((cartesian (list nil)))
> > >    (dolist (set (reverse sets))         ; reverse is only for esthetics
> > >      (let ((new-cartesian nil))
> > >        (dolist (elmt set)
> > >          (dolist (cart cartesian)
> > >            (push (cons elmt cart) new-cartesian)))
> > >        (setf cartesian new-cartesian)))
> > >    cartesian))
> >
> > The code as written is highly nested, and overflows the default
> > "pretty-print" stack in gcl.  You can work around, at least for your
> > example, by doubling the Q_SIZE and IS_SIZE #defines in h/notcomp.h.
> >
> > By default, these are 128 and 256 respectively.  Anyone have a good
> > idea as to what they should be in the default distribution?
> 
> 
> 
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gcl-devel
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]