From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 00F66BC48 for ; Wed, 6 Apr 2005 21:14:55 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j36JEsKq023355 for ; Wed, 6 Apr 2005 21:14:54 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA15708 for ; Wed, 6 Apr 2005 21:14:53 +0200 (MET DST) Received: from saul.cis.upenn.edu (SAUL.CIS.upenn.edu [158.130.12.4]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j36JEq1V005180 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 6 Apr 2005 21:14:53 +0200 Received: from localhost (SAUL.CIS.upenn.edu [158.130.12.4]) by saul.cis.upenn.edu (8.12.10/8.12.9) with ESMTP id j36JEoCP008010; Wed, 6 Apr 2005 15:14:51 -0400 (EDT) Date: Wed, 06 Apr 2005 15:14:50 -0400 (EDT) Message-Id: <20050406.151450.98562588.eijiro_sumii@anet.ne.jp> To: caml-list@inria.fr Cc: sumii@saul.cis.upenn.edu Subject: Re: [Caml-list] ambitious proposal: polymorphic arithmetics From: Eijiro Sumii In-Reply-To: <38697.131.254.50.45.1112810460.squirrel@mail.irisa.fr> References: <20050406.111505.68543084.eijiro_sumii@anet.ne.jp> <87psx7lszi.fsf@qrnik.zagroda> <38697.131.254.50.45.1112810460.squirrel@mail.irisa.fr> X-Mailer: Mew version 3.2 on Emacs 20.7 / Mule 4.1 (AOI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4254352E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4254352C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 eijiro:01 sumii:01 eijiro:01 sumii:01 bool:01 ocaml:01 dispatching:01 irisa:01 bool:01 polymorphic:01 int:01 int:01 caml:02 external:02 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: From: "Marcin 'Qrczak' Kowalczyk" | + can't be treated in the same way, because it won't distinguish | whether it's called as 1 + 1 or true + true. If it returns 2 in the | former case, it would produce a nonsensical bool value in the latter | case. | | OCaml doesn't have a mechanism for making +, - applicable to a limited | set of types and for dispatching their implementation based on the type | rather than on the physical representation. This is an excellent point. (Somebody else also pointed it out in a reply to me.) From: padiolea@irisa.fr > In the module Obj of the caml library there is a function > external is_int : t -> bool = "%obj_is_int" But it doesn't quite work for our purpose here, for example: # type t = A | B ;; type t = A | B # Obj.is_int (Obj.magic A) ;; - : bool = true Eijiro