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.8 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id EC227BB84 for ; Wed, 13 Aug 2008 10:15:09 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiADADA0okhQRFuwiGdsb2JhbACRdwEBAQ8gpRCBVQ X-IronPort-AV: E=Sophos;i="4.32,200,1217800800"; d="scan'208";a="16077050" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 13 Aug 2008 10:15:09 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1KTBVT-00087b-TP; Wed, 13 Aug 2008 09:14:59 +0100 Date: Wed, 13 Aug 2008 09:14:59 +0100 To: Brighten Godfrey Cc: Jon Harrop , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Record field label locality Message-ID: <20080813081459.GA30690@annexia.org> References: <200808102038.40534.jon@ffconsultancy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; locality:01 ocaml:01 ocaml:01 compiler:01 inference:01 undecidable:01 ocaml's:01 syntax:01 inference:01 nodes:01 nodes:01 'open:01 graph':01 trade-offs:01 wrote:01 On Tue, Aug 12, 2008 at 02:03:46PM -0700, Brighten Godfrey wrote: > I think I see what you're getting at. Is it possible to define > compositionality as follows?: I think Jon means that you can copy and paste code around and it still works. > "Removing a type annotation from > correct OCaml code results in correct OCaml code." This is mostly correct. However very occasionally it is necessary to help the compiler out by annotating expressions with types. I believe this is because type inference used by OCaml is undecidable. You'll notice this effect more often if you use OCaml's object system. > I would claim that the current syntax (`g.Graph.nodes' in the above > example) is effectively a type annotation that permits the type > inference that `g' is a `Graph.t'. The annoying bit is that you are > required to use every single time you use a record in `g'. You might want to try renaming the Graph module, ie: module G = Graph ... g.G.nodes ... Or if you have control over the module itself, you could also try renaming the fields to make them unique (eg. g_nodes), at which point you can just 'open Graph'. There are different trade-offs to each approach. Rich. -- Richard Jones Red Hat