English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Static exception in lambda code
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-04-11 (10:04)
From: Sanghyeon Seo <sanxiyn@g...>
Subject: Static exception in lambda code
Luc Maranget suggested that static exception mechanism in lambda code,
namely Lstaticcatch and Lstaticraise, could be used to implement break
and continue.

However, this doesn't work right now. In bytecomp/simplif.ml,
simplify_exits simplify
(catch (seq (exit 1) (assign a b)) with (1) unit) to
(seq unit (assign a b))
which is not appropriate.

The comment says: "simplify catch body with (i ...) handler ... if
(exit i ...) occurs exactly once in body, substitute it with handler".
simplify_exits suppress catch if no exit occurs in body, which is
nice, but this simplification is dangerous if one is to use this
mechanism to implement break and continue.

So, which is the case?
1. The simplification is not safe, so it should be removed.
2. The simplification is consistent with intended semantics of static
catch/raise, so static catch/raise is not directly useful to implement
break/continue or for that matter, return.

Seo Sanghyeon