Version française
Home     About     Download     Resources     Contact us    
Browse thread
Non-tail return
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sanghyeon Seo <sanxiyn@g...>
Subject: Non-tail return
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