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=1.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 95324BC68 for ; Wed, 25 Oct 2006 18:17:31 +0200 (CEST) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.192]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k9PGHUIa020099 for ; Wed, 25 Oct 2006 18:17:31 +0200 Received: by nz-out-0102.google.com with SMTP id 13so127690nzp for ; Wed, 25 Oct 2006 09:17:30 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=hpoJ5SDIS6HlrPs9JSx6LDVUCayIy2OgBD4y2SOK/MQSedwXZnoKSWyM+rdhM362e2QrlySSzKMuh/G6VHdYk63I7YPTp9SxdFKxDssyIzTt1qmdsLEH9xUI72Bg1dndOY7mamnTOuSc3xIBHP+bUbDD3c34Ys53YiWP9+p0Rac= Received: by 10.35.83.6 with SMTP id k6mr1352811pyl; Wed, 25 Oct 2006 09:17:30 -0700 (PDT) Received: by 10.35.72.18 with HTTP; Wed, 25 Oct 2006 09:17:29 -0700 (PDT) Message-ID: Date: Wed, 25 Oct 2006 18:17:29 +0200 From: "Nicolas Pouillard" Sender: nicolas.pouillard@gmail.com To: "Serge Aleynikov" Subject: Re: [Caml-list] camlp4 scope issue Cc: "Dmitri Boulytchev" , bhurt@janestcapital.com, caml-list@inria.fr In-Reply-To: <453F8AF8.4090306@hq.idt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <453F8464.3000808@hq.idt.net> <453FBE38.3030602@tepkom.ru> <453F8AF8.4090306@hq.idt.net> X-Google-Sender-Auth: ad95dc3c1bb2639c X-Miltered: at concorde with ID 453F8E1A.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; camlp:01 syntax:01 iterative:01 syntax:01 bug:01 expr:01 expr:01 notations:01 foo:01 semantics:01 ocaml:01 6.2:98 wrote:01 caml-list:01 binary:01 On 10/25/06, Serge Aleynikov wrote: > Perhaps I am misunderstanding the meaning of ";" in the revised syntax, > however, the 6.2 chapter > (http://caml.inria.fr/pub/docs/manual-camlp4/manual007.html) says that: > > do { e1; e2; e3; e4 } > > is an iterative sequence of expressions, whereas "let ... in" is > reserved for local constructs. > > If so, wouldn't the scope of y in > > let y = 1 in do { a; b; c }; > > be different from: > > let y = 1 in a; b; c; > > Or else how to we indicate in the *revised syntax* the boundary of the > "let ... in" scope? It's not a bug it's a feature :) But a not documented one. Inside a << do { ... } >> you can use << let var = expr1; expr2 >> like << let var = expr1 in expr2 >>. The main goal is to facilitate imperative coding inside a << do {} >>: do { let x = 42; do_that_on x; let y = x + 2; play_with y; } That's nice but undocumented :( Without such a syntax the regular one will make you nest do { ... } notations. do { foo 1; let x = 43 in do { bar x; }; (* x should be out of the scope *) } Alas << let ... in >> and << let ... ; >> have the same semantics inside a << do { ... } >> what I regret because << let ... in >> is not local anymore. In plain OCaml it's different since << ; >> is a binary operator so you must see << let a = () in a; a >> like << let a = () in (a; a) >>. Hope this helps... Best regards, -- Nicolas Pouillard