9fans archive / 1994 / 09 / 9 / prev next
From: bobf@pla... bobf@pla...
Subject: No subject
Date: Thu, 8 Sep 1994 14:13:30 -0400
> #include <alef.h>
>
> void
> main(int argc, byte **argv)
> {
> rescue {
> print("1");
> return;
> }
> rescue {
> print("2");
> raise ;
> }
> raise ;
> }
this is a compiler bug that has been fixed.
> enum {TEXT, AUDIO, VIDEO, MULTI};
>
> void (*f[]) = { /* I'm not sure about f or Mesg.f */
> [TEXT] Mime.ldtext(),
> [AUDIO] Mime.ldaudio(),
> [VIDEO] Mime.ldvideo(),
> [MULTI] Mime.ldmulti(),
> };
>
> and later do (*f[type])(); /* this avoid switch or if else */
use the form .<typename>.function to refer to the functions.
[TEXT] .Mime.ldtext,
[AUDIO] .Mime.ldaudio,
[VIDEO] .Mime.ldvideo,
[MULTI] .Mime.ldmulti,
works with our compiler.
> adt Mime{
> .....
> void write(*Mime,int);
> };
>
> adt Mesg {
> .....
> Mime;
> void write(*Mesg,int);
> };
>
> If I want to access Mime.write through a Mesg object, Is it
> save to use casting?
>
> void
> Mesg.write(Mesg *m,int)
>
> ((Mime *)m)->write(0); /* in order to call MIME.write */
> }
unnamed members can be referenced by their type name. use
m->Mime.write(0);
we are working on a new plan 9 distribution. it contains an Alef
compiler with many bug fixes, some new features, and improved
documentation.