Sujet : Re: Synonym Streams
De : sgonedes1977 (at) *nospam* gmail.com (steve)
Groupes : comp.lang.lispDate : 14. Apr 2024, 17:36:11
Autres entêtes
Message-ID : <8734roez2s.fsf@gmail.com>
References : 1 2 3 4 5
User-Agent : Gnus/5.13 (Gnus v5.13)
Alan Bawden <
alan@csail.mit.edu> writes:
I no longer remember why we designed this whole synonym stream thing.
[ ... ]
bivalent streams are useful.
"In addition, SBCL supports various extensions of ANSI Common Lisp
streams:
*Bivalent Streams*
A type of stream that can read and write both ‘character’ and
‘(unsigned-byte 8)’ values.
I'm not aware of any modern system where I/O has this feature.
POSIX man dup
I would be interested to know of any place that _does_ use synonym
I use the following for type 1 font dissasembler. I do not have the code
right now, but bivalent streams make it much easier to
read-char/read-byte.
;;
;;; Macros
(defmacro with-open-file-stream (direction type options &body body)
`(with-open-file
(,@options :direction ,direction :element-type ,type)
,@body))
(defmacro with-binary-input-stream (options &body forms)
`(with-open-file-stream :input '(unsigned-byte 8) ,options ,@forms))
(defmacro with-ascii-input-stream (options &body forms)
`(with-open-file-stream :input 'character ,options ,@forms))
(defmacro with-ascii-output-stream (options &body forms)
`(with-open-file-stream :output 'character ,options ,@forms))
(defmacro with-binary-output-stream (options &body forms)
`(with-open-file-stream :output '(unsigned-byte 8) ,options ,@forms))
streams to solve some real problem.
i do not have real problems.
- Alan
steve