[m-dev.] Stream2000
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Nov 22 01:25:00 AEDT 2000
On 21-Nov-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> On Wed, Nov 22, 2000 at 12:41:41AM +1100, Fergus Henderson wrote:
> > On 21-Nov-2000, Peter Ross <peter.ross at miscrit.be> wrote:
> > > % :- instance stream__output(impure(your_type)) where [
> > > % (stream__write_char(S, C) --> impure__write_char(S, C))
> > > % ].
> >
> > Instance declarations of that form, where the type in question
> > has more than one type constructor, are forbidden by the Mercury
> > language reference manual. (The two type constructors involved
> > here are impure/1 and your_type/0).
> >
> > Is there some reason why you don't just use a generic instance
> > declaration of the form
> >
> > :- instance stream__input(impure(T)) <= lowlevel(T) where [
> > stream__read_char(S, R) --> impure__read_char(S, R)
> > ].
> > ?
> >
> > (Did we already cover this issue?)
>
> No we didn't, I thought I had used those instance declarations as is for
> the tcp.m module that I have been writing, but on closer examination I
> didn't. I have deleted the comment.
>
> It is not possible to use a generic instance. As there is no generic
> way to determine the stream name, unless we add a new method to the
> impure base type class, but I prefer that sort of meta information to
> reside in a Mercury type, not in the C type that we are likely to be
> using at this level.
Hmm... this is a pity.
> +++ impure.m 2000/11/21 14:00:47
> @@ -8,7 +8,8 @@
> % Main author: petdr
> % Stability: exceptionally low.
> %
> -% An impure interface for describing streams.
> +% An impure interface for describing streams, you may want to also look
> +% at the pure lowlevel interface in lowlevel.m.
s/, you/. You/
Apart from that, this version looks good.
The only other thing I'm concerned about is that the performance is
probably pretty bad, what with all the mutvar stuff (the method
calls are also problematic, but at least they can be specialized).
Anyway, I think this is OK to go in the extras now, if you
package it up with a nice README and an Mmakefile, etc.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list