Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!psuvax1!julius.cs.uiuc.edu!usc!sdd.hp.com!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: Lucid specific stream question Message-ID: <1991Feb1.062927.2260@Think.COM> Date: 1 Feb 91 06:29:27 GMT References: <13256@medusa.cs.purdue.edu> Sender: news@Think.COM Distribution: usa Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 39 In article <13256@medusa.cs.purdue.edu> bouma@cs.purdue.EDU (William J. Bouma) writes: >I want to make *standard-output* and *standard-input* into binary >streams. (stream-element-type *standard-output*) returns 'string-char >as one would expect. Actually, I would expect it to return STRING-CHAR, not 'STRING-CHAR. > But there is no setf method for stream-element- >type. Does anyone know how I could make those streams be of type >'(unsigned-byte 8)? You can't do (setf (stream-element-type ...) ...) for the same reason you can't do (setf (oddp ...) ...). STREAM-ELEMENT-TYPE and ODDP are simply inquiries about the object, not accessors. Binary and character streams are different types of objects (in systems with object-oriented I/O systems, such as Symbolics Genera, they really are different types), so changing the element type would require changing a fundamental aspect of the object. Why would you want to do this to the *standard-xxx* streams, anyway? All functions that use these streams expect them to carry character data. Instead, why don't you construct new streams that interface to the standard streams, but convert between bytes and characters using CHAR-CODE and CODE-CHAR. I believe the mechanisms for creating streams that invoke arbitrary functions are defined in the Advanced User's Guide section of the Lucid manual. If you're expecting this to prevent transformation of your I/O (e.g. converting LF to CR/LF on output, translating CR to LF on input), just setting the element type isn't enough. The default bindings of the *standard-xxx* streams simply forward the data to the Unix stdxx streams., and those transformations are done by the Unix tty driver (when stdout and stdin happen to be terminals), not by Lisp. Disabling this requires performing Unix ioctl() system calls. -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar