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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 07123BC69 for ; Tue, 17 Jul 2007 22:38:53 +0200 (CEST) Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6HKcqTm005002 for ; Tue, 17 Jul 2007 22:38:52 +0200 Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id 3AFDF9DCE; Tue, 17 Jul 2007 16:38:47 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Tue, 17 Jul 2007 16:38:48 -0400 X-Sasl-enc: LKg0z/QTyV2GqTfEIzQCzeSRPnHOTBNDehuNfFYkJAhB 1184704727 Received: from [192.168.1.10] (AMontsouris-753-1-16-141.w83-202.abo.wanadoo.fr [83.202.128.141]) by mail.messagingengine.com (Postfix) with ESMTP id 03DDC792; Tue, 17 Jul 2007 16:38:46 -0400 (EDT) Date: Tue, 17 Jul 2007 22:38:37 +0200 (CEST) From: Martin Jambon X-X-Sender: martin@martin.ec.wink.com To: Brian Hurt Cc: Sam Steingold , caml-list@inria.fr Subject: Re: [Caml-list] List.cons and "::" In-Reply-To: <469D235E.9000008@janestcapital.com> Message-ID: References: <469D2055.5080408@gnu.org> <469D235E.9000008@janestcapital.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 469D28DC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ens-lyon:01 hash:01 syntax:01 infix:01 compiler:01 constructors:01 syntax:01 constructors:01 ocaml:01 2007,:98 wrote:01 wrote:01 caml-list:01 int:01 int:01 On Tue, 17 Jul 2007, Brian Hurt wrote: > Sam Steingold wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Why is :: a syntax, not an infix version of List.cons >> (which for some reason is missing)? >> thanks. >> >> > > So it can be used in pattern matching. Things used in pattern matching the > compiler has to know about, and thus the user can't override. Things not > used in pattern matching can be overridden. So you can redefine + if you > wanted to. I wouldn't recommend it, but you could. > : : and , you can't override. :: and () are just constructors with a special syntax. You can override them: Objective Caml version 3.09.3 # type zarbi = :: of int * int | ();; type zarbi = :: of int * int | () # ();; - : zarbi = () # 1 :: 2;; - : zarbi = :: (1, 2) It's just that constructors are not automatically associated with a function, in OCaml. Martin -- http://martin.jambon.free.fr