Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!cdr.utah.edu!moore From: moore%cdr.utah.edu@cs.utah.edu (Tim Moore) Newsgroups: comp.lang.lisp Subject: Re: read-from-string problem Keywords: read-from-string, keyword arguments Message-ID: <1990Dec20.090713.24536@hellgate.utah.edu> Date: 20 Dec 90 16:07:13 GMT References: <1990Dec20.115130.20493@cs.nott.ac.uk> Organization: University of Utah CS Dept Lines: 37 In article <1990Dec20.115130.20493@cs.nott.ac.uk> nigel@psyc.nott.ac.uk (Nigel Major) writes: >Hello there, > >In an effort to use read-from-string, I came across what >seemed to me to be pretty odd behaviour. At first I thought >it was a bug in my Common Lisp (Lucid 3.0 on a Sun 4/110), but >the same thing happens in AKCL and Poplog CL, so I guess it >is not. Would anyone like to explain it to me? > >> (read-from-string "abcdefgh" :start 2 :end 3) >abc >3 >> (read-from-string "abcdefgh" :end 3 :start 2) >cdefgh >8 READ-FROM-STRING takes two optional parameters, EOF-ERROR-P and EOF-VALUE, like most reader functions. You were unwittingly supplying values for those parameters, so in your first example you only specified a value for :end (but not :start), and vice versa for the second example. > >I had rather assumed that the first call should return cd, >and that whatever the first call had returned, the second call >should return the same. CLtL says of read-from-string that the >keywords :start and :end delimit a substring in the same way as >for other string functions. They do. Both calls should return C: (read-from-string "abcdefgh" nil nil :end 3 :start 2) C 3 Tim Moore moore@cs.utah.edu {bellcore,hplabs}!utah-cs!moore "Ah, youth. Ah, statute of limitations." -John Waters