Menu

#328 Mistake in LISP tutorial

closed-fixed
doc (13)
5
2006-03-29
2006-03-29
Ronald BG.
No

I think I have found a mistake in the LISP tutorial included with GNU CLISP distributions:

Excerpt from line 711-722 of the tutorial:
-------------------------------------------------------------------------------
> (setf a (make-array 1)) ;setf on a variable is equivalent to setq
#(NIL)
> (push 5 (aref a 1)) ;push can act like setf ;???
(5)
> (pop (aref a 1)) ;so can pop
5
> (setf (aref a 1) 5)
5
> (incf (aref a 1)) ;incf reads from a place, increments,
6 ;and writes back
> (aref a 1)
6
-------------------------------------------------------------------------------

I think all the "(aref a 1)" forms above are wrong: Because we created array with one element, the only valid array index is zero; accessing index 1 (with the form "(aref a 1)") will result in an error.

Discussion

  • Sam Steingold

    Sam Steingold - 2006-03-29

    Logged In: YES
    user_id=5735

    thank you for your bug report.
    the bug has been fixed in the CVS tree.
    you can either wait for the next release (recommended)
    or check out the current CVS tree (see http://clisp.cons.org\)
    and build CLISP from the sources (be advised that between
    releases the CVS tree is very unstable and may not even build
    on your platform).

     
  • Sam Steingold

    Sam Steingold - 2006-03-29
    • assigned_to: haible --> sds
    • status: open --> closed-fixed
     

Log in to post a comment.