Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.lisp > #59524

Re: Synonym Streams

From steve <sgonedes1977@gmail.com>
Newsgroups comp.lang.lisp
Subject Re: Synonym Streams
References <6pd1+E7bUWxwHGM59@bongo-ra.co> <uqtv0o$1fckl$2@dont-email.me> <23FZrFyCKlaZfJP1R@bongo-ra.co> <20240219092306.348@kylheku.com> <867cj0qfbq.fsf_-_@williamsburg.bawden.org>
Date 2024-04-14 11:36 -0400
Message-ID <8734roez2s.fsf@gmail.com> (permalink)

Show all headers | View raw


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

Back to comp.lang.lisp | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

CLHS on *DEBUG-IO* and others Spiros Bousbouras <spibou@gmail.com> - 2024-02-17 14:08 +0000
  Re: CLHS on *DEBUG-IO* and others Kaz Kylheku <433-929-6894@kylheku.com> - 2024-02-17 16:34 +0000
  Re: CLHS on *DEBUG-IO* and others Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-02-18 22:06 +0000
    Re: CLHS on *DEBUG-IO* and others Spiros Bousbouras <spibou@gmail.com> - 2024-02-19 12:09 +0000
      Re: CLHS on *DEBUG-IO* and others Kaz Kylheku <433-929-6894@kylheku.com> - 2024-02-19 17:40 +0000
        Synonym Streams Alan Bawden <alan@csail.mit.edu> - 2024-02-19 17:06 -0500
          Re: Synonym Streams Spiros Bousbouras <spibou@gmail.com> - 2024-02-20 17:54 +0000
          Re: Synonym Streams steve <sgonedes1977@gmail.com> - 2024-04-14 11:36 -0400
            Re: Synonym Streams Alan Bawden <alan@csail.mit.edu> - 2024-04-14 18:49 -0400
            Re: Synonym Streams Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-15 00:49 +0000
              Re: Synonym Streams steve <sgonedes1977@gmail.com> - 2024-04-19 13:44 -0400
        Re: CLHS on *DEBUG-IO* and others Spiros Bousbouras <spibou@gmail.com> - 2024-02-20 17:47 +0000
          Re: CLHS on *DEBUG-IO* and others Kaz Kylheku <433-929-6894@kylheku.com> - 2024-02-20 18:18 +0000

csiph-web