Path: csiph.com!tncsrv06.tnetconsulting.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!69.80.99.27.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 14 Apr 2024 15:36:12 +0000 From: steve Newsgroups: comp.lang.lisp Subject: Re: Synonym Streams References: <6pd1+E7bUWxwHGM59@bongo-ra.co> <23FZrFyCKlaZfJP1R@bongo-ra.co> <20240219092306.348@kylheku.com> <867cj0qfbq.fsf_-_@williamsburg.bawden.org> Date: Sun, 14 Apr 2024 11:36:11 -0400 Message-ID: <8734roez2s.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:qbsZmmH4/M+cVEPXqJbnOM7FpaE= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 54 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-uIGVqe6N2HiQaplOV95qlEaJCfkl3iucTl75mA/wmV6WL+ScRTaxdSZ5DXt6oBst4npVpOCI+AxGuKj!y/R+O1OCSeTbzc8dPZpp0cCGXKhuhT5pCy5o3O6jz+DgGQ== X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Xref: csiph.com comp.lang.lisp:59524 Alan Bawden 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