Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

linux: because a PC is a terrible thing to waste (ksh@cis.ufl.edu put this on Tshirts in '93)


devel / comp.lang.lisp / Re: READ-SEQUENCE and fill pointers

SubjectAuthor
* READ-SEQUENCE and fill pointersSpiros Bousbouras
+* Re: READ-SEQUENCE and fill pointersZyni Moë
|`- Re: READ-SEQUENCE and fill pointersSpiros Bousbouras
`* Re: READ-SEQUENCE and fill pointersTom Russ
 `- Re: READ-SEQUENCE and fill pointersZyni Moë

1
READ-SEQUENCE and fill pointers

<8OJW8iQLHBx39AOzJ@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17085&group=comp.lang.lisp#17085

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!wMjcvFyyQbKkD1DyxkS8fQ.user.46.165.242.91.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: READ-SEQUENCE and fill pointers
Date: Mon, 2 May 2022 14:16:21 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <8OJW8iQLHBx39AOzJ@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="37649"; posting-host="wMjcvFyyQbKkD1DyxkS8fQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Server-Commands: nowebcancel
X-Notice: Filtered by postfilter v. 0.9.2
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Mon, 2 May 2022 14:16 UTC

(let ((arr (make-array 20 :fill-pointer 0 :initial-element 1))
(s (make-string-input-stream "abcdefg")))
(read-sequence arr s)
(close s)
(format t "~a~%" (aref arr 0)))

prints 1 .But if I change the above code to :fill-pointer 1 then it
prints a .This both on SBCL and clisp so I'm guessing it's standard.
But from where in CLHS does it follow that READ-SEQUENCE should not
read beyond where the fill pointer is ? I find the behaviour counter-
intuitive. Perhaps I don't understand the logic of fill pointers but
I have been assuming that you allocate for a vector a number of
elements which you think will prove useful over the running of your
programme and at each point in time the fill pointer indicates up to
which position your vector has meaningful values. If you do
READ-SEQUENCE into your vector , you indicate that you want the vector
filled with as much as the vector can fit in and the stream can
provide. So I would find it more intuitive that , if the stream can
provide characters to fill up to and including position N in the
vector and before the READ-SEQUENCE the fill pointer had some value
M <= N then after the READ-SEQUENCE the fill pointer will have the
value N+1 .

--
There's nothing I like less than bad arguments for a view that I hold dear.
Daniel Dennett

Re: READ-SEQUENCE and fill pointers

<t4ov28$a57$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17086&group=comp.lang.lisp#17086

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: READ-SEQUENCE and fill pointers
Date: Mon, 2 May 2022 15:58:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <t4ov28$a57$1@dont-email.me>
References: <8OJW8iQLHBx39AOzJ@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 2 May 2022 15:58:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="560dd5a8e3d3a808ef357799b11ae951";
logging-data="10407"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+y/bJFbFRoiSdrPw0bqb0CnAh9yMpJODo="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:sGAoT6Aqy4XEh3BwPUoAtrgnvE4=
sha1:frNQoZdVnDiWpYlNAqVFYqt3W34=
 by: Zyni Moë - Mon, 2 May 2022 15:58 UTC

Spiros Bousbouras <spibou@gmail.com> wrote:
> But from where in CLHS does it follow that READ-SEQUENCE should not
> read beyond where the fill pointer is ?

read-sequence sequence stream &key start end => position
[...]
position---an integer greater than or equal to zero, and less than or
equal to the length of the sequence.

And from length (is link in CLHS)

length n. (of a sequence) the number of elements in the sequence.
(Note that if the sequence is a vector with a fill pointer, its length
is
the same as the fill pointer even though the total allocated size of
the
vector might be larger.)

--
the small snake

Re: READ-SEQUENCE and fill pointers

<a07a2263-5c13-451a-9ada-80c8f2915d1fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17087&group=comp.lang.lisp#17087

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a37:b543:0:b0:69f:71de:23fb with SMTP id e64-20020a37b543000000b0069f71de23fbmr8971911qkf.90.1651510928161;
Mon, 02 May 2022 10:02:08 -0700 (PDT)
X-Received: by 2002:a05:6808:124d:b0:325:788d:e23d with SMTP id
o13-20020a056808124d00b00325788de23dmr30255oiv.267.1651510927483; Mon, 02 May
2022 10:02:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Mon, 2 May 2022 10:02:07 -0700 (PDT)
In-Reply-To: <8OJW8iQLHBx39AOzJ@bongo-ra.co>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:8000:7603:1703:5d8d:e17f:7e2e:978a;
posting-account=05zmAwoAAAAJZM-3jv1hCWLHGZQceqwA
NNTP-Posting-Host: 2603:8000:7603:1703:5d8d:e17f:7e2e:978a
References: <8OJW8iQLHBx39AOzJ@bongo-ra.co>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a07a2263-5c13-451a-9ada-80c8f2915d1fn@googlegroups.com>
Subject: Re: READ-SEQUENCE and fill pointers
From: taruss@google.com (Tom Russ)
Injection-Date: Mon, 02 May 2022 17:02:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 28
 by: Tom Russ - Mon, 2 May 2022 17:02 UTC

On Monday, May 2, 2022 at 7:16:28 AM UTC-7, Spiros Bousbouras wrote:
> (let ((arr (make-array 20 :fill-pointer 0 :initial-element 1))
> (s (make-string-input-stream "abcdefg")))
> (read-sequence arr s)
> (close s)
> (format t "~a~%" (aref arr 0)))
>
> prints 1 .But if I change the above code to :fill-pointer 1 then it
> prints a .This both on SBCL and clisp so I'm guessing it's standard.
> But from where in CLHS does it follow that READ-SEQUENCE should not
> read beyond where the fill pointer is ?

It may not say that in so many words, but I would assume it is implied
as Zyni notes. In particular, the default END value for READ-SEQUENCE
is NIL, which is interpreted as the length of the sequence. And as Zyni
mentions, this is the active length of the vector with fill pointer.

If you were to change your output to be
(format t "~a ~a~%" arr (aref arr 0))
you would see that the value of ARR is empty: #()

AREF can still access the inactive element 0 because AREF is specifically
defined to ignore fill pointers and thus able to access inactive elements
of the vector. [I had been wondering why that worked].

You could also examine the return value of READ-SEQUENCE, which would
also show that no values were read. The consequence of this is that the
READ-SEQUENCE function will not extend arrays, but only operate on the
active values.

Re: READ-SEQUENCE and fill pointers

<t4p9r9$uru$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17088&group=comp.lang.lisp#17088

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no_email@invalid.invalid (Zyni Moë)
Newsgroups: comp.lang.lisp
Subject: Re: READ-SEQUENCE and fill pointers
Date: Mon, 2 May 2022 19:02:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <t4p9r9$uru$1@dont-email.me>
References: <8OJW8iQLHBx39AOzJ@bongo-ra.co>
<a07a2263-5c13-451a-9ada-80c8f2915d1fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 2 May 2022 19:02:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="560dd5a8e3d3a808ef357799b11ae951";
logging-data="31614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/h/8++7iSIh69WN34vUQjGNI0s9qAzZU="
User-Agent: NewsTap/5.5 (iPad)
Cancel-Lock: sha1:f9OxKdnHaQpDmtXOIv1vk+eLlgk=
sha1:fOiBI2QDPAIdgqhzmNfGDYQd4Fg=
 by: Zyni Moë - Mon, 2 May 2022 19:02 UTC

Tom Russ <taruss@google.com> wrote:

> You could also examine the return value of READ-SEQUENCE, which would
> also show that no values were read. The consequence of this is that the
> READ-SEQUENCE function will not extend arrays, but only operate on the
> active values.
>

One consequence of this is this thing

... compiler does fancy calculation about bounds, optimises bounds
checks ...
(read-sequence ...)
... calculations still valid ...

--
the small snake

Re: READ-SEQUENCE and fill pointers

<f2Px0=0ZwbRnzLwxD@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17093&group=comp.lang.lisp#17093

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.cyber23.de!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: READ-SEQUENCE and fill pointers
Date: Tue, 3 May 2022 19:55:49 -0000 (UTC)
Organization: Cyber23 news
Message-ID: <f2Px0=0ZwbRnzLwxD@bongo-ra.co>
References: <8OJW8iQLHBx39AOzJ@bongo-ra.co> <t4ov28$a57$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 3 May 2022 19:55:49 -0000 (UTC)
Injection-Info: news.cyber23.de;
logging-data="7582"; mail-complaints-to="abuse@cyber23.de"
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
In-Reply-To: <t4ov28$a57$1@dont-email.me>
 by: Spiros Bousbouras - Tue, 3 May 2022 19:55 UTC

On Mon, 2 May 2022 15:58:00 -0000 (UTC)
Zyni Moë <no_email@invalid.invalid> wrote:
> Spiros Bousbouras <spibou@gmail.com> wrote:
> > But from where in CLHS does it follow that READ-SEQUENCE should not
> > read beyond where the fill pointer is ?
>
> read-sequence sequence stream &key start end => position
> [...]
> position---an integer greater than or equal to zero, and less than or
> equal to the length of the sequence.
>
> And from length (is link in CLHS)
>
> length n. (of a sequence) the number of elements in the sequence.
> (Note that if the sequence is a vector with a fill pointer, its length
> is
> the same as the fill pointer even though the total allocated size of
> the
> vector might be larger.)

That settles it ; thanks.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor