But from where in CLHS does it follow that READ-SEQUENCE should not
read beyond where the fill pointer is ?
(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 ?
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.
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.)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 298 |
Nodes: | 16 (2 / 14) |
Uptime: | 23:45:35 |
Calls: | 6,678 |
Calls today: | 1 |
Files: | 12,222 |
Messages: | 5,341,916 |
Posted today: | 1 |