Джерело:
Common Lisp Tips
Дата публікації:
16/02/2017 15:59
Постійна адреса новини:
http://www.vsinovyny.com/8323847
16/02/2017 15:59 // Common Lisp Tips
I’ve seen this idiom a few times when working with a binary stream:
(let ((elements-read (read-sequence buffer stream)))
...)
While the return value is the number of elements read in that situation, it’s a useful coincidence in a common case. The actual return value of read-sequence is:
the index of the first element of sequence that was not updated
Therefore, treating the return value as the number of elements read is completely wrong if you use the start option to read-sequence.
For example, if stream has one or more elements available to read:
(read-sequence buffer stream :start 42 :end 43)
=> 43
The actual number of elements read is 1, not 43.
| « |
Наступна новина з архіву Опубликованы фотографии 42 крупнейших астероидов Солнечной системы |
Попередня новина з архіву Making a directory from a pathname |
» | |
|
|
||||