caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl>
To: caml-list@inria.fr
Subject: [Caml-list] Looking up exceptions in a dictionary
Date: Mon, 5 Nov 2001 10:00:55 +0000 (UTC)	[thread overview]
Message-ID: <slrn9ucoqn.4an.qrczak@qrnik.zagroda> (raw)

I want to set up a framework for registering exception constructors and
specific exception values, and later translate exceptions arrived using
registered translation functions. The problem boils down to having
a dictionary indexed by exception constructors and exception values.

I haven't found the exception representation described. Is the
following description accurate?

An exception is a block whose first field is a pointer used to
distinguish among exception constructors, and the rest are arguments.
The constructor pointer points to a one-field block which contains
a string pointer containing the constructor name.

I think the dictionary can be constructed as I say below. Can it be
done in a better way?

Since the real thing to be looked up is a pointer, and pointers don't
have a stable hash, the first step is a Hashtbl.t indexed by string
values - names of constructors, to quickly narrow the search. Names
are insufficient to reliably distinguish exceptions, so under each
name there is an association list holding actual constructor pointers
for all exceptions having a given name, looked up using List.assq. Now
we have found the constructor. A regular Hashtbl.t here can be used
to find specific exception values if needed, which can be done by
exn value assuming that the constructors match.

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^
QRCZAK

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-11-05  9:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-05 10:00 Marcin 'Qrczak' Kowalczyk [this message]
2001-11-05  9:29 ` Fabrice Le Fessant
2001-11-05 10:18 ` Xavier Leroy

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=slrn9ucoqn.4an.qrczak@qrnik.zagroda \
    --to=qrczak@knm.org.pl \
    --cc=caml-list@inria.fr \
    /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).