caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ville-Pertti Keinonen <will@exomi.com>
To: "Daniel M. Albro" <albro@humnet.ucla.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] OCaml popularity
Date: Fri, 14 Mar 2003 11:05:56 +0200	[thread overview]
Message-ID: <2ABB7A8B-55FC-11D7-8D68-000393863F70@exomi.com> (raw)
In-Reply-To: <1047620947.1866.21.camel@giynz>


> Break simulated by continuation passing (I think that's
> what this is -- it looks like a call/cc to me, anyway)

Sort of, except that the continuation can't be used outside the 
function called by escape.  Here's a different approach (this is 
essentially a variation of the recursive style, because you need to 
make sure the continuation is called as a tail call):

let _ =
   let ary = [| 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12 |] in
   let rec loop f j =
     if j = 10 || ary.(j) = 5 then f ()
     else loop f (j + 1)
   in
     let rec outer i =
       if i <= 1_000_000_000 then
         loop (fun _ -> outer (i + 1)) 0
     in
       outer 1

This style is useful in some cases when you can write a significant 
part of your program using continuations.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-03-14  9:06 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-13  7:09 Daniel M. Albro
2003-03-13 16:48 ` Neel Krishnaswami
2003-03-13 21:29 ` Karl Zilles
2003-03-13 21:36   ` Daniel M. Albro
2003-03-13 21:42   ` Daniel M. Albro
     [not found]     ` <15985.1204.814698.939943@h00045a4799d6.ne.client2.attbi.com>
2003-03-14  5:49       ` Daniel M. Albro
2003-03-14  9:05         ` Ville-Pertti Keinonen [this message]
2003-03-14  9:13           ` Daniel M. Albro
2003-03-13 21:53   ` Brian Hurt
  -- strict thread matches above, loose matches on Subject: below --
2003-03-15 16:27 Oliver Bandel
2003-03-15 17:55 ` Sergey Goldgaber
2003-03-14 22:14 Daniel M. Albro
2003-03-13 14:39 [oliver: Re: [Caml-list] OCaml popularity] Oliver Bandel
2003-03-13 16:35 ` [Caml-list] OCaml popularity Michael Schuerig
2003-03-12 23:53 [oliver: Re: [Caml-list] OCaml popularity] Oliver Bandel
2003-03-13  1:34 ` [Caml-list] OCaml popularity Michael Schuerig
2003-03-12 17:40 isaac gouy
2003-03-06 23:27 Graham Guttocks
2003-03-10 20:43 ` Paul Steckler
2003-03-10 23:48 ` Gerd Stolpmann
2003-03-11  0:18   ` Brian Hurt
2003-03-17 23:49   ` Graham Guttocks
2003-03-11  1:43 ` Nicolas Cannasse
2003-03-11 10:23   ` Pierre Weis
2003-03-11 14:27     ` Guillaume Marceau
2003-03-11 16:16       ` David Brown
2003-03-12  2:32       ` Nicolas Cannasse
2003-03-12 10:51         ` Alex Romadinoff
2003-03-12 18:24         ` Max Kirillov
2003-03-11 19:02     ` Graham Guttocks
2003-03-12 17:12       ` Richard W.M. Jones
2003-03-12 18:08         ` Alwyn Goodloe
2003-03-12 22:34           ` Michael Schuerig
2003-03-12 23:13             ` Martin Weber
2003-03-12 23:35               ` Michael Schuerig
2003-03-13  8:02                 ` Alessandro Baretta
2003-03-13 10:23                   ` Michael Schuerig
2003-03-12 23:35             ` Brian Hurt
2003-03-12 23:18         ` Daniel Bünzli
2003-03-12 23:47           ` Brian Hurt
2003-03-13  2:15         ` William Lovas
2003-03-13  3:44           ` Graham Guttocks
2003-03-13  9:31           ` Richard W.M. Jones
     [not found]           ` <20030313095232.GC347@first.in-berlin.de>
2003-03-13 20:50             ` William Lovas
2003-03-13 21:17               ` Oliver Bandel
2003-03-13 22:01                 ` Brian Hurt
2003-03-13 22:17                 ` Oliver Bandel
2003-03-14  6:33                 ` Michal Moskal
2003-03-14 11:50                   ` Markus Mottl
2003-03-14 15:38                     ` Oliver Bandel
2003-03-14 10:13               ` MikhailFedotov
2003-03-14 10:30                 ` Johann Spies
2003-03-13  8:09       ` Pierre Weis
2003-03-15  1:43     ` Tushar Samant
2003-03-15  8:19       ` Andreas Eder
2003-03-11 16:26   ` Fred Yankowski
2003-03-12 18:59 ` Martin Weber
2003-03-12 20:24   ` Xavier Leroy
2003-03-13  0:42   ` Graham Guttocks

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=2ABB7A8B-55FC-11D7-8D68-000393863F70@exomi.com \
    --to=will@exomi.com \
    --cc=albro@humnet.ucla.edu \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).