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=AWL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 26BEABBC1 for ; Thu, 10 Apr 2008 09:09:45 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAGJa/UfAXQIm/2dsb2JhbACqYQ X-IronPort-AV: E=Sophos;i="4.25,633,1199660400"; d="scan'208";a="11287892" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 10 Apr 2008 09:09:44 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m3A79igd010309 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 10 Apr 2008 09:09:44 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArAFAGJa/UeBrw8EWGdsb2JhbACRPwEbJ5hf X-IronPort-AV: E=Sophos;i="4.25,633,1199660400"; d="scan'208";a="10681986" Received: from ext.lri.fr ([129.175.15.4]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Apr 2008 09:09:44 +0200 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 45D33A4726; Thu, 10 Apr 2008 09:09:44 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7-ESataZGZSj; Thu, 10 Apr 2008 09:09:35 +0200 (CEST) Received: from [129.175.4.117] (lri4-117 [129.175.4.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ext.lri.fr (Postfix) with ESMTP id ED7B0A4727; Thu, 10 Apr 2008 09:09:31 +0200 (CEST) Message-ID: <47FDBDA1.8080901@lri.fr> Date: Thu, 10 Apr 2008 09:11:29 +0200 From: =?UTF-8?B?SmVhbi1DaHJpc3RvcGhlIEZpbGxpw6J0cmU=?= User-Agent: Thunderbird 1.5.0.14ubu (X11/20080306) MIME-Version: 1.0 To: Sanghyeon Seo Cc: caml-list@inria.fr Subject: Re: [Caml-list] break and continue for OCaml References: <5b0248170804091859s75c3f725s2db53f48fba6735c@mail.gmail.com> In-Reply-To: <5b0248170804091859s75c3f725s2db53f48fba6735c@mail.gmail.com> X-Enigmail-Version: 0.94.2.0 OpenPGP: url=http://www.lri.fr/~filliatr/mykey.asc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 47FDBD38.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; filliatre:01 lri:01 ocaml:01 ocaml:01 sparcs:01 bytecomp:01 bytegen:01 bytecode:01 exn:01 lri:01 filliatr:01 seo:98 wrote:01 typing:01 caml-list:01 Sanghyeon Seo wrote: > I have the first cut of patch to implement break and continue inside > for and while loops for OCaml. > > http://sparcs.kaist.ac.kr/~tinuviel/devel/ocaml/ > > Patch is against OCaml 3.10.2. All the meat is in bytecomp/bytegen.ml. > Currently bytecode only. I am working on natvie code and error > handling when break is used outside loop etc but I thought "releasing > early" could be useful. > > What do you think? A comment on typing break and continue: If I read your patch correctly, you're giving type "unit" to both expressions "break" and "continue". I was rather expecting type 'a instead, as for "raise exn". It could be useful in situations like this while ... do let x = ... [if ... then break else ...] ... in ... done Said otherwise, break and continue can be simply encoded with exceptions try while ... do try .... loop body where break is raise Break ... .... and continue is raise Continue ... with Continue -> () done with Break -> () and thus should be typed the same way. -- Jean-Christophe Filliâtre http://www.lri.fr/~filliatr/