Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ml > Re: [smlnj] cal...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 951 of 973
Post > Topic >>

Re: [smlnj] callcc and throw vs. capture and escape

by Matthias Blume <find@[EMAIL PROTECTED] > Apr 26, 2008 at 12:05 AM

Ronald Garcia <ron.garcia@[EMAIL PROTECTED]
> writes:

> Hi,
>
> I am using SMLNJ and trying to understand the difference between
> callcc/throw and capture/escape.  As far as I can tell, they differ
> only in how they treat exception handlers; however the textual
> descriptions of them that I have seen are not clear to me.
>
> For instance:
>
> capture f
> Apply f to the "current continuation". If f invokes this continuation
> with argument x, it is as if (capture f) had returned x as a result,
> except that the exception-handler is not properly restored (it is
> still that of the invoker).
>
> This description makes it sound as though each continuation has only
> one exception handler.  However my intuition for exceptions suggests
> that handlers should be sprinkled throughout the continuation (one for
> every "handle" expression in the current dynamic extent).  Is the
> description I quote above written in terms of how exceptions are
> implemented in SMLNJ (i.e. does a continuation have a single
> "exception handler" that handles all exceptions), or does SML really
> have a notion of a single exception handler?

Exception handlers are dynamically nested, so only the innermost one
is in effect at any given time.  However, notice that the handler
installed by a "handle" expression will usually have an implicit
default "catch-all" case that chains back to the previous handler.
(This is, unless you write your own explicit catch-all case.)

As a result, at any given time, there is only one exception handler.
In SML/NJ, the handler is implemented as a continuation that is stored
in a global variable.  An alternative (and most likely better)
approach is to pass the exception handler as an implicit argument to
every function call, but for historical reasons this is currently not
the case in SML/NJ.

> Is there a formal specification of capture and escape somewhere?

No, not that I know of.  This is an SML/NJ-ism anyway, which was added
as a workaround for problems caused by the fact that the global
exception handler variable is manipulated by side-effecting
operations.

Matthias
 




 2 Posts in Topic:
[smlnj] callcc and throw vs. capture and escape
Ronald Garcia <ron.gar  2008-04-10 08:19:59 
Re: [smlnj] callcc and throw vs. capture and escape
Matthias Blume <find@[  2008-04-26 00:05:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 19:57:35 CDT 2008.