Re: Bug with *print-base* 36
Gary Byers <[email protected]> Sat, 7 Jun 2003 19:47:04 -0600 (MDT)
| Newsgroups | gmane.lisp.openmcl.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 8 Jun 2003, Patrik Nordebo wrote: > While porting Gilbert Baumann's web browser closure to OpenMCL, I ran > into what looks like a bug in the printer when *print-base* is bound > to 36 and a bignum is printed. The bug is in ccl::%pr-integer, but the > code looked too hairy for me to fix. Below is a transcript that > demonstrates the problem. > > Welcome to OpenMCL Version (Beta: Darwin) 0.13.5! > ? > ? (setq *print-base* 36) > 10 > ? (expt 36 7) > > Error: Array index Z out of bounds for #<SIMPLE-VECTOR 35> . > > While executing: CCL::%PR-INTEGER > > Type :POP to abort. > Type :? for other options. > 1 > :pop > ? (setq *print-base* 35) > 10 > ? (expt 36 7) > 17M10L71 > ? (1- (expt 35 7)) > YYYYYYY > ? (ccl::%pr-integer (expt 36 7) 36) > > Error: Array index 35 out of bounds for #<SIMPLE-VECTOR 35> . > > While executing: CCL::%PR-INTEGER > > Type :POP to abort. > Type :? for other options. > 1 > > The vector that's one element too small is hardwired into the definition of %PR-INTEGER itself; it's used to estimate the number of digits (in the current radix) that'll be needed to print a 32-bit chunk of a bignum. It's the initial value of the variable SIZE-VECT, and I have no idea why it's defined with #.(vector ...) instead of with #(...); I have a hunch that this code was written a long, long time ago. Adding another "7" at the end of the vector would work (if you could print a 32-bit integer in 7 base-35 digits, it can't require more digits in base 36). If you try to fix this by interactively redefining %PR-INTEGER, note that it depends on macros that're defined in files that're ordinarily REQUIREd during compilation (see the EVAL-WHEN near the top of "ccl:level-0;l0-int.lisp".) Thanks.