caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* break and continue for OCaml
@ 2008-04-10  1:59 Sanghyeon Seo
  2008-04-10  7:09 ` [Caml-list] " Luc Maranget
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Sanghyeon Seo @ 2008-04-10  1:59 UTC (permalink / raw)
  To: caml-list

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?

-- 
Seo Sanghyeon


^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: [Caml-list] break and continue for OCaml
@ 2008-04-11  3:44 Andrew I. Schein
  0 siblings, 0 replies; 15+ messages in thread
From: Andrew I. Schein @ 2008-04-11  3:44 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 909 bytes --]

I took the exception approach in a camlp4 macro: pa_breakcont

http://code.google.com/p/ocaml-break-continue/

There are timings before/after on the wiki section of that page that
demonstrate the overhead.

Also, pa_breakcont changes rather than adds to the grammar increasing
likelihood of conflict with other extensions.

Hopefully, Sanghyeon can fix both of these drawbacks with his approach.

-Andy



> On Thu, Apr 10, 2008 at 04:12:49PM +0200, David Allsopp wrote:
> > Is there therefore any reasonable performance gain over implementing
> > break/continue as a camlp4 extension rather than as a compiler patch?
>
> The posted patch turns the break/continue into jump instructions
> (well, jump bytecodes), which should be moderately faster than pushing
> an exception stack frame / unwinding the stack.
>
> Rich.
>
> --
> Richard Jones
> Red Hat
>
>



-- 
Andrew I. Schein


web: www.andrewschein.com

[-- Attachment #2: Type: text/html, Size: 1329 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-04-11  3:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-10  1:59 break and continue for OCaml 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
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

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).