* Non-tail return
@ 2008-04-15 14:07 Sanghyeon Seo
0 siblings, 0 replies; only message in thread
From: Sanghyeon Seo @ 2008-04-15 14:07 UTC (permalink / raw)
To: caml-list
Richard Jones suggested that type-safe return statement which
immediately returns from the innermost function would be useful. So I
developed an implementation. His sample code (from Extlib) works
as-is.
http://sparcs.kaist.ac.kr/~tinuviel/devel/ocaml/
Some notes:
* This depends on nontail exit patch I did as a part of break/continue
patch. break-continue-v2 was broken to break-continue-v3 and
nontail-exit-v1.
* A stack of function's return type is maintained. "return e" causes
unification of "e" and return type on the top of the stack. "return e"
itself is typed as unit.
* Function is translated with implicit catch around body, and return
is translated to raise. Simplification removes implicit catch when no
return is used, so existing codes should compile same.
--
Seo Sanghyeon
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-04-15 14:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-15 14:07 Non-tail return Sanghyeon Seo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox