From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 0F6BDBC48 for ; Wed, 6 Apr 2005 20:01:04 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j36I13qa030286 for ; Wed, 6 Apr 2005 20:01:03 +0200 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 UAA12859 for ; Wed, 6 Apr 2005 20:01:03 +0200 (MET DST) From: padiolea@irisa.fr Received: from smtp.irisa.fr (smtp.irisa.fr [131.254.254.26]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j36I12tB015366 for ; Wed, 6 Apr 2005 20:01:03 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost.irisa.fr (Postfix) with ESMTP id C2819FB1C; Wed, 6 Apr 2005 20:01:02 +0200 (CEST) Received: from smtp.irisa.fr ([131.254.254.26]) by localhost (meli.irisa.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08073-04; Wed, 6 Apr 2005 20:01:00 +0200 (CEST) Received: from mail.irisa.fr (melo.irisa.fr [131.254.254.28]) by smtp.irisa.fr (Postfix) with ESMTP id E42CDFACE; Wed, 6 Apr 2005 20:01:00 +0200 (CEST) Received: from 131.254.50.45 (SquirrelMail authenticated user padiolea) by mail.irisa.fr with HTTP; Wed, 6 Apr 2005 20:01:00 +0200 (CEST) Message-ID: <38697.131.254.50.45.1112810460.squirrel@mail.irisa.fr> In-Reply-To: <87psx7lszi.fsf@qrnik.zagroda> References: <20050406.111505.68543084.eijiro_sumii@anet.ne.jp> <87psx7lszi.fsf@qrnik.zagroda> Date: Wed, 6 Apr 2005 20:01:00 +0200 (CEST) Subject: Re: [Caml-list] ambitious proposal: polymorphic arithmetics To: "Marcin 'Qrczak' Kowalczyk" Cc: caml-list@inria.fr User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: by amavisd-new at irisa.fr X-Miltered: at nez-perce with ID 425423DF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 425423DE.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; irisa:01 caml-list:01 eijiro:01 sumii:01 eijiro:01 sumii:01 ocaml:01 dispatching:01 bool:01 pointer:01 bool:01 ocaml:01 ...:98 writes:01 polymorphic:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.2 required=5.0 tests=NO_REAL_NAME autolearn=disabled version=3.0.2 X-Spam-Level: > Eijiro Sumii writes: > >> So here it goes: why don't we have polymorphic +, -, etc. while we >> have polymorphic =, <, etc.? > [...] > > 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. In the module Obj of the caml library there is a function external is_int : t -> bool = "%obj_is_int" I guess that the value are represented internally as "cells" and that cells have a bit indicating wether it is an int or a pointer (and also a bit for the gc) By using more bits we could know wether or not it is a float, and so have also a function is_float: t -> bool and so we could then code a "generic" + function (but it would lead to an overhead due to the dispatch). Nevertheless I dont think that making + generic is an ambitious/important feature. My big wish for ocaml would be to have some better tracing facilities, a generic print function, and the possibilty to print backtraces, some features available in langage such as perl and that makes the life of the developper far easier.