home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / lisp / lispnews / text0184.txt < prev    next >
Encoding:
Text File  |  1985-11-10  |  2.6 KB  |  71 lines

  1. Hard to believe but it was less than two and a half years ago that
  2. someone was having trouble using Franz arrays...
  3.  
  4.     Date: 17 Jul 1981 17:06:22-PDT
  5.     From: CSVAX.jkf at Berkeley
  6.     To: FININ@WHARTON-10
  7.     cc: franz-friends at MIT-MC
  8.     Subject: Re: ... the maclisp-style array package.
  9.     In-reply-to: Your message of 17 Jul 1981 1347-PDT (Friday).
  10.  
  11.         From: FININ@WHARTON-10
  12.         Subject: ... the maclisp-style array package.
  13.  
  14.         ...
  15.         [3] We've been having problems with the MacLisp compatable array
  16.             package - it doesn't work!  Does anyone have a debugged version?
  17.  
  18.     Can you be more specific? We use it in Vax Macsyma without any problems.
  19.     Personally I feel that Maclisp arrays were invented by a madman and no new
  20.     code should be written using them.  
  21.  
  22.     -- john foderaro
  23.  
  24. Well, I used the Maclisp array package because I didn't want to waste
  25. time writing my own.  Instead I spent hours looking for the bug in this
  26. code:
  27.  
  28.     -> (let ((factorial (*array () () 100.)))
  29.             (store (factorial 0) 1)
  30.         (do ((i 1 (1+ i)))
  31.             ((= i 100.))
  32.                 (store (factorial i) (times i (factorial (1- i)))))
  33.             (factorial 10.))
  34.     285656
  35.  
  36. To make a long story short, this lossage is because the second argument
  37. to *array being nil tells the garbage collector not to scan the
  38. array.  The factorial of ten gets tossed in the bit bucket, where it
  39. unfortunately looks like a fixnum.  To fix the example, change the
  40. first line of the example to
  41.  
  42.     -> (let ((factorial (*array () t 100.)))
  43.  
  44. To save someone else from excruciatingly wrong answers, change the
  45. documentation in Section 2.
  46.  
  47.     (*array 's_name 's_type 'x_dim1 ... 'x_dimn)
  48.     (array s_name s_type x_dim1 ... x_dimn)
  49.  
  50.          WHERE:   s_type may be one of t, nil,  fixnum,  flonum,
  51.                   fixnum-block and flonum-block.
  52.            ...
  53. <                  In FRANZ LISP arrays of type t, nil, fix-
  54. <          num and flonum are equivalent and the elements of
  55. <          these  arrays  can  be  any  type of lisp object.
  56. ---
  57. >                  In  FRANZ  LISP arrays of type t, fixnum,
  58. >          and  flonum  are  equivalent  and the elements of
  59. >          these arrays can  be  any  type  of  lisp object.
  60. >          Type nil arrays may also contain any type of lisp
  61. >          object,  but  they are not marked  by the garbage
  62. >          collector  (see 9.2.2)  and can lose data if used
  63. >          incorrectly.
  64.            Fixnum-block and  flonum-block  arrays  are  res-
  65.            tricted  to  fixnums and flonums respectively and
  66.            are used mainly to communicate with foreign func-
  67.            tions (see 8.4).
  68.  
  69. Dan
  70.  
  71.