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.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 2DBDCBC6B for ; Wed, 27 Jun 2007 16:18:39 +0200 (CEST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.177]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5REIc0w006880 for ; Wed, 27 Jun 2007 16:18:38 +0200 Received: from [141.84.136.30] (helo=[152.78.96.56]) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis), id 0MKxQS-1I3YLt2vci-0008L0; Wed, 27 Jun 2007 16:18:38 +0200 Message-ID: <468271CE.7040406@functionality.de> Date: Wed, 27 Jun 2007 15:18:54 +0100 From: Thomas Fischbacher User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060607 Debian/1.7.12-1.2 X-Accept-Language: en MIME-Version: 1.0 To: Jon Harrop Cc: 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> In-Reply-To: <200706271453.06045.jon@ffconsultancy.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX18sWPpqLGukZeDysRwLuvuAEoEhAkRo4NRUiIB ntITocL+eYwuSmeSAHrG7ytmpqQQIl0W6wWC84kHT3iTqxv4JZ Zm8C+U3YltB98F6Gi4PhA== X-Miltered: at discorde with ID 468271BE.003 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; memoize:01 hashtbl:01 hashtbl:01 val:01 ocaml:01 hash:01 wrote:01 caml-list:01 strings:01 strings:01 data:02 string:02 string:02 implicit:03 let:03 Jon Harrop wrote: > Basically, you memoize strings: > > # let symbol = > let m = Hashtbl.create 1 in > fun string -> > try Hashtbl.find m string with Not_found -> > Hashtbl.add m string string; > string;; > val symbol : '_a -> '_a = ...which is, of course, just a consequence of the OCaml drawback that there is no proper "symbol" data type (which actually would be useful, in particular in conjunction with proper EQ hash tables)... By the way, the Perl interpreter does the same thing with script-constant strings, also using this to provide "effective almost-symbols". -- best regards, Thomas Fischbacher tf@functionality.de