From: Jon Haugsand
Subject: How does the stream class hierarchies look like?
Date:
Message-ID: <yzoln9jh57m.fsf@procyon.nr.no>
I have Allegro installed on a Linux (RH 5.2) and have problem with the
following expressions that does not work:
(defclass teststream (fundamental-binary-input-stream) ())
(let ((a (make-array 100 :element-type '(unsigned-byte 8))))
(with-open-file (str "/etc/passwd" :direction :input
:class 'teststream
:element-type '(unsigned-byte 8))
(read-sequence a str)))
I get the following error message:
Error: No methods applicable for generic function
#<STANDARD-GENERIC-FUNCTION STREAM-READ-BYTE> with args (#<TESTSTREAM @ #x204fdd3a>)
of classes (TESTSTREAM)
[condition type: PROGRAM-ERROR]
Any suggestions?
(This message is a resend of an earlier which I never got answers
from. Now I include the comp.lang.lisp group.)
--
Jon Haugsand
Norwegian Computing Center, <http://www.nr.no/engelsk/>
<···············@nr.no> Pho: +47 22852608 / +47 22852500,
Fax: +47 22697660, Pb 114 Blindern, N-0314 OSLO, Norway
Jon Haugsand <········@procyon.nr.no> writes:
> I have Allegro installed on a Linux (RH 5.2) and have problem with the
> following expressions that does not work:
>
> (defclass teststream (fundamental-binary-input-stream) ())
>
> (let ((a (make-array 100 :element-type '(unsigned-byte 8))))
> (with-open-file (str "/etc/passwd" :direction :input
> :class 'teststream
> :element-type '(unsigned-byte 8))
> (read-sequence a str)))
>
> I get the following error message:
> Error: No methods applicable for generic function
> #<STANDARD-GENERIC-FUNCTION STREAM-READ-BYTE> with args (#<TESTSTREAM @ #x204fdd3a>)
> of classes (TESTSTREAM)
> [condition type: PROGRAM-ERROR]
>
> Any suggestions?
Section 3.0 of streams.html explains that
FUNDAMENTAL-BINARY-INPUT-STREAM is a non-instantiable mixin
class. You're supposed to implement STREAM-READ-BYTE yourself for your
class.
Perhaps you could tell us what you are trying to do?
--
Lieven Marchand <···@bewoner.dma.be>
If there are aliens, they play Go. -- Lasker
From: Jon Haugsand
Subject: Re: How does the stream class hierarchies look like?
Date:
Message-ID: <yzon1tyvlvx.fsf@procyon.nr.no>
* Lieven Marchand
> Perhaps you could tell us what you are trying to do?
First, I try to learn CL and understand the CLOS. I could not imagine
that one was not able to make subclasses of the stream classes
straightforward. Second, I try to program around a bug in Linux,
Allegro, multithreading and/or the sound driver in Linux. What I
really do is defining an audio-stream class, subclass of
FUNDAMENTAL-BINARY-INPUT-STREAM and FUNDAMENTAL-BINARY-OUTPUT-STREAM
with the only redefinition so far is that I make an :AFTER method to
the STREAM-WRITE-BYTE generic function so that I am certain that the
buffer is flushed to the sound device when a certain threshould (size
and timeinterval) is reached.
But thanks for your help.
--
Jon Haugsand
Norwegian Computing Center, <http://www.nr.no/engelsk/>
<···············@nr.no> Pho: +47 22852608 / +47 22852500,
Fax: +47 22697660, Pb 114 Blindern, N-0314 OSLO, Norway
Jon Haugsand <········@procyon.nr.no> writes:
> What I really do is defining an audio-stream class, subclass of
> FUNDAMENTAL-BINARY-INPUT-STREAM and FUNDAMENTAL-BINARY-OUTPUT-STREAM
> with the only redefinition so far is that I make an :AFTER method to
> the STREAM-WRITE-BYTE generic function so that I am certain that the
> buffer is flushed to the sound device when a certain threshould
> (size and timeinterval) is reached.
In that case I think it's easier to do something like
(defclass test-stream (binary-stream) ())
(defmethod stream-write-byte :after ((stream test-stream) integer)
(flush-output stream))
You can search dejanews for a more advanced solution by Erik Naggum
that can change streams that have already been opened. The context was
a question about how to make a stream unbuffered.
--
Lieven Marchand <···@bewoner.dma.be>
If there are aliens, they play Go. -- Lasker
In article <···············@procyon.nr.no>, Jon Haugsand
<········@procyon.nr.no> wrote:
> I have Allegro installed on a Linux (RH 5.2) and have problem with the
> following expressions that does not work:
>
> (defclass teststream (fundamental-binary-input-stream) ())
>
> (let ((a (make-array 100 :element-type '(unsigned-byte 8))))
> (with-open-file (str "/etc/passwd" :direction :input
> :class 'teststream
> :element-type '(unsigned-byte 8))
> (read-sequence a str)))
>
> I get the following error message:
> Error: No methods applicable for generic function
> #<STANDARD-GENERIC-FUNCTION STREAM-READ-BYTE> with args
(#<TESTSTREAM @ #x204fdd3a>)
> of classes (TESTSTREAM)
> [condition type: PROGRAM-ERROR]
>
> Any suggestions?
Try using BINARY-INPUT-FILE-STREAM... directly
d
From: Jon Haugsand
Subject: Re: How does the stream class hierarchies look like?
Date:
Message-ID: <yzon1tyfe9o.fsf@procyon.nr.no>
* David D. Smith
> > (defclass teststream (fundamental-binary-input-stream) ())
> Try using BINARY-INPUT-FILE-STREAM... directly
Why? Then I cannot do what I want. (Unless I misunderstand you.)
--
Jon Haugsand
Norwegian Computing Center, <http://www.nr.no/engelsk/>
<···············@nr.no> Pho: +47 22852608 / +47 22852500,
Fax: +47 22697660, Pb 114 Blindern, N-0314 OSLO, Norway
In article <···············@procyon.nr.no>, Jon Haugsand
<········@procyon.nr.no> wrote:
> * David D. Smith
> > > (defclass teststream (fundamental-binary-input-stream) ())
>
> > Try using BINARY-INPUT-FILE-STREAM... directly
>
> Why? Then I cannot do what I want. (Unless I misunderstand you.)
You did not misunderstand me. I answered the question you asked: Open a
file of (unsigned-byte 8) for reading only, with efficient input to an
(unsigned-byte 8) vector.
...
In article <···············@procyon.nr.no>, Jon Haugsand
<········@procyon.nr.no> wrote:
> I have Allegro installed on a Linux (RH 5.2) and have problem with the
> following expressions that does not work:
>
> (defclass teststream (fundamental-binary-input-stream) ())
>
> (let ((a (make-array 100 :element-type '(unsigned-byte 8))))
> (with-open-file (str "/etc/passwd" :direction :input
> :class 'teststream
> :element-type '(unsigned-byte 8))
> (read-sequence a str)))
>
> I get the following error message:
> Error: No methods applicable for generic function
> #<STANDARD-GENERIC-FUNCTION STREAM-READ-BYTE> with args
(#<TESTSTREAM @ #x204fdd3a>)
> of classes (TESTSTREAM)
> [condition type: PROGRAM-ERROR]
>
> Any suggestions?
Try using BINARY-INPUT-FILE-STREAM... directly
d