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 WAA14963; Thu, 3 Apr 2003 22:40:48 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 WAA15033 for ; Thu, 3 Apr 2003 22:40:47 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h33Kej519821; Thu, 3 Apr 2003 22:40:45 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA14527; Thu, 3 Apr 2003 22:40:44 +0200 (MET DST) From: Pierre Weis Message-Id: <200304032040.WAA14527@pauillac.inria.fr> Subject: Re: [Caml-list] How can I check for the use of polymorphic equality? In-Reply-To: <3E8C8F27.1070001@cs.caltech.edu> from Jason Hickey at "Apr 3, 103 11:44:39 am" To: jyh@cs.caltech.edu (Jason Hickey) Date: Thu, 3 Apr 2003 22:40:44 +0200 (MET DST) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; pierre:01 weis:01 caml-list:01 runtime:01 hickey:01 626:99 792:99 generic:01 assertion:01 statically:01 cristal:01 bool:01 equality:01 int:01 polymorphic:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk [...] > In the meantime, I use a hack to help catch errors at runtime. The idea > is this. > 1. The type you care about is probably abstract. > 2. Add an abstract value to the data in your type, so that equality > will fail (at runtime). [...] > -- > Jason Hickey http://www.cs.caltech.edu/~jyh > Caltech Computer Science Tel: 626-395-6568 FAX: 626-792-4257 Hi, Your trick is fine and clever but it seems overcomplex to me: to check usage of equality, I would just redefine equality! If you add, in the scope of each module (for instance by systematically opening a basic code module), a new binding for ( = ) as in let ( = ) (x : 'a) (y : 'a) = assert false;; then the generic equality is no more used and any occurrence of ( = ) will raise an assertion failure at runtime. You could also define assign a special type for your ``fake'' generic equality that would trigger a typecheckeking error statically. For instance, define let ( = ) (x : int) (y : bool) = assert false;; You probably will catch every reasonable usage of ( = ) that way... Simple, no ? Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners