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.1 required=5.0 tests=AWL,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 C94D3BC69 for ; Tue, 8 May 2007 00:26:13 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.226]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l47MQBCt014983 for ; Tue, 8 May 2007 00:26:13 +0200 Received: by nz-out-0506.google.com with SMTP id l8so2075137nzf for ; Mon, 07 May 2007 15:26:09 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=SF/mN6CC3mUIKUIDLKqHlBuJww7w1wVQKzTMctgK84IKTOulNS7rzgaLMuoK/cUFdKYVv2AX8l8V6ya4mgh6+9vbr+8FUJBUxZMUJqXdggyCy1xOKFZmfy5fr2AkkzHBkr4PFHlSq9L4TgFt+FXgnD/H7+5a6KLAtM63843k94k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=fsb0NM3oBOTxy22+51uDK5t64h7ClR5u3VKq7Pj3yF3ow/8+uhbGSx0gG/7qWXTDNQ4T02nOKE1pcmin+K5e617o1YO05hrtgy1hkWNt8J5BFUnKQhnFMGUvKqsW64R3WGZe8E6CuYhC/MxpvK6kowvKxok2oifcwxPP/qeYLuw= Received: by 10.114.61.1 with SMTP id j1mr2332177waa.1178576769482; Mon, 07 May 2007 15:26:09 -0700 (PDT) Received: by 10.114.123.9 with HTTP; Mon, 7 May 2007 15:26:08 -0700 (PDT) Message-ID: <90823c940705071526x87f78b4i74bc73b11ee9a890@mail.gmail.com> Date: Tue, 8 May 2007 02:26:08 +0400 From: "Dmitry Bely" To: "Caml List" Subject: F# lightweight syntax for Ocaml with camlp4 - possible? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 463FA783.001 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 463FA783.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; syntax:01 ocaml:01 camlp:01 syntax:01 fsharp:01 tokens:01 parser:01 printf:01 printf:01 ocaml:01 camlp:01 parsing:01 hen:98 hen:98 experimental:01 Some times ago F# team has introduced a new Caml syntax option called "lightweight". From the F# manual: http://research.microsoft.com/fsharp/manual/lexyacc.aspx [...] F# supports the optional use of lightweight syntax through the use of whitespace to make indentation significant. At the time of this release this is an experimental feature, though it is assumed that its use will become widespread. The indentation-aware syntax option is a conservative extension of the explicit language syntax, in the sense that it simply lets you leave out certain tokens such as in and ;; by having the parser take indentation into account. This can make a surprising difference to the readability of code. [...] Basic rules by example // Without the light syntax option // 'done' is required let FunctionSample() = let tick x = printf "tick %d\n" x in let tock x = printf "tock %d\n" x in let choose f g h x = if f x then g x else h x in for i = 0 to 10 do choose (fun n -> n%2 = 0) tick tock i done; printf "done!\n" // When the light syntax option is // enabled 'done' is optional and the scope of // structured constructs such as match, for, while // and if/then/else is determined by indentation. #light let FunctionSample() = let tick x = printf "tick %d\n" x let tock x = printf "tock %d\n" x let choose f g h x = if f x then g x else h x for i = 0 to 10 do choose (fun n -> n%2 = 0) tick tock i printf "done!\n" [end of quote] Could the same idea be implemented for Ocaml with Camlp4? Can it use an indentation level while parsing? I realize that the third syntax will be 'too much' but it really seems to be quite useful... - Dmitry Bely