From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 44F22BD73 for ; Tue, 16 Aug 2005 23:51:13 +0200 (CEST) Received: from pih-relay04.plus.net (pih-relay04.plus.net [212.159.14.131]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j7GLpCiF032380 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 16 Aug 2005 23:51:13 +0200 Received: from [80.229.56.224] (helo=chetara) by pih-relay04.plus.net with esmtp (Exim) id 1E59Kx-0002I1-0V for caml-list@yquem.inria.fr; Tue, 16 Aug 2005 22:51:11 +0100 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Snd question Date: Tue, 16 Aug 2005 22:42:50 +0100 User-Agent: KMail/1.7.2 References: <161F0D30A699A84A8B7435B62BCE33B30360E19F@APS-MSG-01.southpacific.corp.microsoft.com> <200508161734.38909.jon@ffconsultancy.com> <20050816181604.GA21719@furbychan.cocan.org> In-Reply-To: <20050816181604.GA21719@furbychan.cocan.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508162242.50803.jon@ffconsultancy.com> X-Miltered: at concorde with ID 43025FD0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 sml:01 trivial:01 sml:01 ad-hoc:01 polymorphism:01 ocaml:01 ...:98 ...:98 frog:98 wrote:01 wrote:01 structures:01 define:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Tuesday 16 August 2005 19:16, Richard Jones wrote: > On Tue, Aug 16, 2005 at 05:34:38PM +0100, Jon Harrop wrote: > > Currently, you cannot match [|1; ...|] in OCaml. > > Yes! Or, "prefix" ^ str. Unless you have a substring type I think that'll have to be: "prefix"^_ Anyway, we've had this discussion before. :-) > > From my limited experience of SML, it is more of a pain than a benefit. > > It'd be pretty trivial anyway to define the SML # operators > using camlp4. Are you sure? I was under the impression that macros didn't know about the type system. Has anyone done any ad-hoc polymorphism (if that's the right jargon, I mean the equivalent of "+" for both int and float in SML) for containers? I haven't finished it yet but I've recently been playing with a term-level mini-Caml interpreter that I was going to add this functionality to. So "fold", "map" and so on are built into the language and can be applied to the built-in data structures set, list and array. Also, the pattern "1::2::3::_" can be applied to any container type. The main problem that I can think of is the unpredictable memory use of substring/subarray types when they keep their "parent" around for longer than expected. This makes me think that it might be a bad idea... -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. Objective CAML for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists