From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Richard Jones <rich@annexia.org>
Cc: Sanghyeon Seo <sanxiyn@gmail.com>, caml-list@inria.fr
Subject: Re: [Caml-list] break and continue for OCaml
Date: Thu, 10 Apr 2008 16:05:45 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.64.0804101549410.9417@martin.ec.wink.com> (raw)
In-Reply-To: <20080410133956.GA4065@annexia.org>
On Thu, 10 Apr 2008, Richard Jones wrote:
> On Thu, Apr 10, 2008 at 10:59:16AM +0900, Sanghyeon Seo wrote:
>> What do you think?
>
> When you've done that, how about a type-safe return statement? It
> should immediately return from the inner-most function, allowing one
> to return a value.
>
> Here's a usage scenario (modified from Extlib, it would be even
> shorter with 'break'):
>
> (* Find the index of string 'sub' within 'str' *)
> let find str sub =
> let sublen = String.length sub in
> if sublen = 0 then return 0;
>
> let len = String.length str in
> for i = 0 to len-sublen do
> let j = ref 0 in
> while String.unsafe_get str (i + !j) = String.unsafe_get sub !j do
> incr j;
> if !j = sublen then return i
> done;
> done;
> raise Not_found
I'm OK with the intent, but what should happen in such cases:
module A =
struct
let a = break
let b = continue
let c = return true
let d = lazy (return 123)
let e () = Lazy.force d
end
Martin
--
http://wink.com/profile/mjambon
http://mjambon.com
next prev parent reply other threads:[~2008-04-10 14:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-10 1:59 Sanghyeon Seo
2008-04-10 7:09 ` [Caml-list] " Luc Maranget
2008-04-10 7:11 ` Jean-Christophe Filliâtre
2008-04-10 14:12 ` David Allsopp
2008-04-10 14:41 ` Richard Jones
2008-04-10 13:39 ` Richard Jones
2008-04-10 14:05 ` Martin Jambon [this message]
2008-04-10 14:19 ` Richard Jones
2008-04-10 14:24 ` Michael Wohlwend
2008-04-10 14:35 ` Martin Jambon
2008-04-10 14:38 ` Michael Wohlwend
2008-04-10 22:23 ` Florian Weimer
2008-04-10 20:35 ` Eric Cooper
2008-04-11 0:14 ` Micha
2008-04-11 3:44 Andrew I. Schein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0804101549410.9417@martin.ec.wink.com \
--to=martin.jambon@ens-lyon.org \
--cc=caml-list@inria.fr \
--cc=rich@annexia.org \
--cc=sanxiyn@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox