From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA10498; Mon, 5 Nov 2001 10:59:37 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA10254 for ; Mon, 5 Nov 2001 10:59:36 +0100 (MET) Received: from mail.mimuw.edu.pl (paf87.warszawa.sdi.tpnet.pl [217.96.225.87]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fA59xWH26180 for ; Mon, 5 Nov 2001 10:59:33 +0100 (MET) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id LAA05128 for caml-list@inria.fr; Mon, 5 Nov 2001 11:00:58 +0100 X-Authentication-Warning: qrnik.zagroda: news set sender to Marcin 'Qrczak' Kowalczyk using -f From: "Marcin 'Qrczak' Kowalczyk" Subject: [Caml-list] Looking up exceptions in a dictionary Date: Mon, 5 Nov 2001 10:00:55 +0000 (UTC) Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: X-Trace: qrnik.zagroda 1004954455 4440 192.168.0.1 (5 Nov 2001 10:00:55 GMT) X-Complaints-To: abuse@localhost NNTP-Posting-Date: Mon, 5 Nov 2001 10:00:55 +0000 (UTC) User-Agent: slrn/0.9.7.2 (Linux) To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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