From: Nikodemus Siivola
Subject: string-input-stream question
Date: 
Message-ID: <bi4ghg$pbj$1@nyytiset.pp.htv.fi>
What happens when the string being used as input source is modified?

Eg:

 (let ((s (make-string 3 :initial-element #\o)))
   (with-input-from-string (f s :start 0 :end 3)
        (setf (char s 0) #\f)
        (read f)))  ;; => FOO or OOO

The relevant point in CLHS says: "String is evaluated first, and var is
bound to a character input string stream that supplies characters from
the subsequence of the resulting string bounded by start and end."

"Subsequence" makes me think that OOO should be expected, as 
generally subsequences have a distinct identity, but CMUCL, SBCL, ACL 
and CLISP all seem to agree on FOO.

What am I missing here?

Cheers,

 -- Nikodemus

From: Barry Margolin
Subject: Re: string-input-stream question
Date: 
Message-ID: <UQq1b.344$mD.233@news.level3.com>
In article <············@nyytiset.pp.htv.fi>,
Nikodemus Siivola  <······@random-state.net> wrote:
>What happens when the string being used as input source is modified?
>
>Eg:
>
> (let ((s (make-string 3 :initial-element #\o)))
>   (with-input-from-string (f s :start 0 :end 3)
>        (setf (char s 0) #\f)
>        (read f)))  ;; => FOO or OOO
>
>The relevant point in CLHS says: "String is evaluated first, and var is
>bound to a character input string stream that supplies characters from
>the subsequence of the resulting string bounded by start and end."
>
>"Subsequence" makes me think that OOO should be expected, as 
>generally subsequences have a distinct identity, but CMUCL, SBCL, ACL 
>and CLISP all seem to agree on FOO.
>
>What am I missing here?

No, a subsequence does *not* have a distinct identity.  It's just the
portion of the original sequence indicated by the given starting and ending
positions.  If you want a distinct sequence, call SUBSEQ.

-- 
Barry Margolin, ··············@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Christopher C. Stacy
Subject: Re: string-input-stream question
Date: 
Message-ID: <u65kps6qg.fsf@dtpq.com>
>>>>> On Fri, 22 Aug 2003 15:41:40 GMT, Barry Margolin ("Barry") writes:

 Barry> In article <············@nyytiset.pp.htv.fi>,
 Barry> Nikodemus Siivola  <······@random-state.net> wrote:
 >> What happens when the string being used as input source is modified?
 >> 
 >> Eg:
 >> 
 >> (let ((s (make-string 3 :initial-element #\o)))
 >> (with-input-from-string (f s :start 0 :end 3)
 >> (setf (char s 0) #\f)
 >> (read f)))  ;; => FOO or OOO
 >> 
 >> The relevant point in CLHS says: "String is evaluated first, and var is
 >> bound to a character input string stream that supplies characters from
 >> the subsequence of the resulting string bounded by start and end."
 >> 
 >> "Subsequence" makes me think that OOO should be expected, as 
 >> generally subsequences have a distinct identity, but CMUCL, SBCL, ACL 
 >> and CLISP all seem to agree on FOO.
 >> 
 >> What am I missing here?

 Barry> No, a subsequence does *not* have a distinct identity.  It's
 Barry> just the portion of the original sequence indicated by the
 Barry> given starting and ending positions.  If you want a distinct
 Barry> sequence, call SUBSEQ.

Just to clarify, the value returned from SUBSEQ has its own identity,
because that copies a sequence.  Similarly, one could call MAKE-ARRAY
using the :DISPLACED-TO option, and get a string that shared the
elements of the original string -- and the resulting array would
have its own identity.

In your example above, you create a stream that reads from a given
string.  That string has its own identity.  The subsequence may or 
may not have its own identity (may or may not even exist), but in 
any event it is sharing the array elements of the original string.