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

Unexpected READ-FROM-STRING behavior



>Date: Tue, 21 Jul 92 16:57:34 -0400
>From: cornell@freya.cs.umass.edu
>To: info-mcl@cambridge.apple.com
>Cc: bug-mcl@cambridge.apple.com
>Subject: Unexpected READ-FROM-STRING behavior
>
>Dear Folks:
>
>Am I loosing my mind? I'm getting behavior from READ-FROM-STRING that
>seems wrong. It concerns the optional :start argument, which I'm

This is a classic trap in Common Lisp, and it gets 'em every time.

READ-FROM-STRING has the dubious honor of having two optional
arguments (EOF-ERROR-P and EOF-VALUE) *as well as* keyword arguments.

If you say (read-from-string string :start 1), the 1 is taken as
EOF-VALUE, not the string keyword value. You have to provide
the optional args before starting in on the keywords, for example:

? (let ((string "(a 23 b)"))
    (read-from-string string nil :eof :start 1))
A
3

ps. By the way, there's no need to send mail to both bug-mcl and info-mcl,
since all mail sent to info-mcl goes to bug-mcl anyway.