From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 3317CBC6B for ; Wed, 27 Jun 2007 18:01:25 +0200 (CEST) Received: from looneymail-a4.g.dreamhost.com (lax-green-bigip-5.dreamhost.com [208.113.200.5]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5RG1OI6029923 for ; Wed, 27 Jun 2007 18:01:24 +0200 Received: from [192.168.101.117] (unknown [66.84.219.53]) by looneymail-a4.g.dreamhost.com (Postfix) with ESMTP id A6DBB125FAF for ; Wed, 27 Jun 2007 09:01:22 -0700 (PDT) Message-ID: <468289D0.1010701@SmokejumperIT.com> Date: Wed, 27 Jun 2007 11:01:20 -0500 From: Robert Fischer Organization: Smokejumper Consulting User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments References: <200706271314.35134.jon@ffconsultancy.com> <1A1D6F56-B3DB-4552-969C-9859482175AC@lrde.epita.fr> <200706271453.06045.jon@ffconsultancy.com> <200706271528.l5RFSKF04408@virtutech.se> <46828488.3000006@SmokejumperIT.com> <200706271548.l5RFmiS04436@virtutech.se> In-Reply-To: <200706271548.l5RFmiS04436@virtutech.se> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 468289D4.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 mattias:01 compile-time:01 sig:01 val:01 val:01 struct:01 hashtbl:01 hashtbl:01 bool:01 bool:01 equality:01 wrote:01 caml-list:01 strings:01 I'm happier with Ocaml every day. :-D Robert Fischer IT Firefighter Smokejumper Consulting Mattias Engdegård wrote: >> I don't have a top-level with me right now, so I'm shooting from the >> hip, but I don't think it is a compile-time error to attempt to use the >> referential equality operator on two different types. >> > > No, (==) : 'a -> 'a , so this would work: > > module Sym : sig > type t > val symbol : string -> t > val str : t -> string > end = struct > type t = string > let symbol = > let m = Hashtbl.create 1 in > fun s -> > try Hashtbl.find m s > with Not_found -> (Hashtbl.add m s s; s) > let str s = s > end;; > > # "toto" == "alpha" ;; > - : bool = false > # Sym.symbol "alpha" == Sym.symbol "alpha" ;; > - : bool = true > # Sym.symbol "alpha" == "alpha" ;; > Characters 22-29: > Sym.symbol "alpha" == "alpha" ;; > ^^^^^^^ > This expression has type string but is here used with type Sym.t > > The cost is a slightly clumsier use of symbols as strings (Symbol.str), > but my feeling is that the extra safety is worth it. > >