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 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 9FFCABBC1 for ; Thu, 10 Apr 2008 16:25:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAFbA/UfAXQIm/2dsb2JhbACrbw X-IronPort-AV: E=Sophos;i="4.25,636,1199660400"; d="scan'208";a="10703934" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Apr 2008 16:25:59 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m3AEPqjb030797 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 10 Apr 2008 16:25:59 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: As8AABvA/UfC2fJWfGdsb2JhbACRTQEBCwUCBQkWmWc X-IronPort-AV: E=Sophos;i="4.25,636,1199660400"; d="scan'208";a="24846158" Received: from anchor-post-36.mail.demon.net ([194.217.242.86]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 Apr 2008 16:25:54 +0200 Received: from orion.metastack.com ([80.177.38.218]) by anchor-post-36.mail.demon.net with esmtp (Exim 4.67) id 1Jjxir-000PII-MD for caml-list@inria.fr; Thu, 10 Apr 2008 14:25:53 +0000 Received: from countertenor (dynamic71.vpdn.csx.cam.ac.uk [131.111.7.71]) (authenticated bits=0) by orion.metastack.com (8.13.4/8.13.3) with ESMTP id m3AEC7sN004410 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 10 Apr 2008 15:12:10 +0100 From: "David Allsopp" To: References: <5b0248170804091859s75c3f725s2db53f48fba6735c@mail.gmail.com> <47FDBDA1.8080901@lri.fr> Subject: RE: [Caml-list] break and continue for OCaml Date: Thu, 10 Apr 2008 16:12:49 +0200 Organization: MetaStack Solutions Ltd. Message-ID: <003e01c89b15$001f9f30$017ca8c0@countertenor> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 In-Reply-To: <47FDBDA1.8080901@lri.fr> Thread-Index: Acia2cq8Cf6Qa8PYTpWqqisqZNXqfwAOtKYg X-Scanned-By: MIMEDefang 2.63 on 172.16.28.218 X-Miltered: at discorde with ID 47FE2370.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 camlp:01 compiler:01 filliatre:01 ocaml:01 sparcs:01 bytecomp:01 bytegen:01 bytecode:01 exn:01 filliatre:01 lri:01 filliatr:01 seo:98 wrote:01 Is there therefore any reasonable performance gain over implementing break/continue as a camlp4 extension rather than as a compiler patch? David Jean-Christophe Filli=E2tre wrote: > Sanghyeon Seo wrote: > > I have the first cut of patch to implement break and continue inside > > for and while loops for OCaml. > >=20 > > http://sparcs.kaist.ac.kr/~tinuviel/devel/ocaml/ > >=20 > > 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. > >=20 > > 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 =3D ... [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. > > --=20 > Jean-Christophe Filli=E2tre > http://www.lri.fr/~filliatr/