9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Alberto Nava beto@plan9.cs.su.oz.au
Subject: a few questions about alef
Date: Mon,  5 Sep 1994 01:01:49 -0400	[thread overview]
Message-ID: <19940905050149.pEFhZUNcmo6jvTIyLzaV-ouuZo17Vv4Dk9ACODUk_-g@z> (raw)


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 */
}






             reply	other threads:[~1994-09-05  5:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-05  5:01 Alberto [this message]
1994-09-05  7:16 Hans-Peter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19940905050149.pEFhZUNcmo6jvTIyLzaV-ouuZo17Vv4Dk9ACODUk_-g@z \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).