9fans archive / 1994 / 09 / 7 / prev next
From: Alberto Nava beto@pla...
Subject: a few questions about alef
Date: Mon, 5 Sep 1994 01:01:49 -0400
I've been working with alef in the last weeks
and I have a few questions about it.
1) I had some problems with rescue. For example the
output of this programs is "2+" and not "21". If I name
the recues then the output is ok, 21.
#include <alef.h>
void
main(int argc, byte **argv)
{
rescue {
print("1");
return;
}
rescue {
print("2");
raise ;
}
raise ;
}
2) Do we have something like pointer to functions of an
adt in alef. I would like to write something like this.
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 */
3) Some time in an adt I declared another unamed adt
which has functions which common names. For example:
#include <alef.h>
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 */
}