Is READ-LINE required to return a fresh string?

This is a discussion on Is READ-LINE required to return a fresh string? within the lisp forums in Programming Languages category; Hi, I don't think I see anything in the READ-LINE specification that requires the first return value to be a fresh string. Does anybody else see such a requirement? (Otherwise, are conforming programs supposed to copy any line they want to modify or hold on to?) -- RmK...

Go Back   Application Development Forum > Programming Languages > lisp

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-27-2008, 05:09 PM
Richard M Kreuter
Guest
 
Default Is READ-LINE required to return a fresh string?

Hi,

I don't think I see anything in the READ-LINE specification that
requires the first return value to be a fresh string. Does anybody
else see such a requirement? (Otherwise, are conforming programs
supposed to copy any line they want to modify or hold on to?)

--
RmK
Reply With Quote
  #2  
Old 08-27-2008, 05:27 PM
Rainer Joswig
Guest
 
Default Re: Is READ-LINE required to return a fresh string?

In article <871w0atbat.fsf@progn.net>,
Richard M Kreuter <kreuter@progn.net> wrote:

> Hi,
>
> I don't think I see anything in the READ-LINE specification that
> requires the first return value to be a fresh string. Does anybody
> else see such a requirement? (Otherwise, are conforming programs
> supposed to copy any line they want to modify or hold on to?)
>
> --
> RmK


I also can't see it specified.

But I would expect CL:READ-LINE to return a fresh string
on each call.

I would also expect that once CL:READ-LINE returns a string
the user program can use it and change it without affecting
other read/write operations.

I can't remember seeing code that makes other assumptions.

Typical use would be to iterate over the lines of a stream
and collect all the read lines in some data structure.
I would expect that there is no reuse of strings going
on.

--
http://lispm.dyndns.org/
Reply With Quote
  #3  
Old 08-27-2008, 07:23 PM
Scott Burson
Guest
 
Default Re: Is READ-LINE required to return a fresh string?

On Aug 27, 2:27 pm, Rainer Joswig <jos...@lisp.de> wrote:
> In article <871w0atbat....@progn.net>,
> Richard M Kreuter <kreu...@progn.net> wrote:
>
> > Hi,

>
> > I don't think I see anything in the READ-LINE specification that
> > requires the first return value to be a fresh string. Does anybody
> > else see such a requirement? (Otherwise, are conforming programs
> > supposed to copy any line they want to modify or hold on to?)

>
> I also can't see it specified.
>
> But I would expect CL:READ-LINE to return a fresh string
> on each call.


I think this has to be considered the default in Lisp. In order for
it to be allowable for a function that returns some object to reuse an
object it previously returned, the specification would have to say so
explicitly. Hmm, I see the CLHS is not particularly consistent: the
page for CONS says "creates a fresh cons", and those for MAKE-ARRAY
and MAKE-INSTANCE say "creates and returns ..."; but that for LIST
simply says "returns a list containing the supplied objects", and
similarly the MAKE-STRING page just says "returns...". Still, there's
no doubt that for LIST or MAKE-STRING to reuse a previously returned
list or string would be completely bizarre.

-- Scott
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 01:34 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.