[plt-scheme] Parameters versus continuation marks

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jan 14 09:07:50 EST 2008

At Mon, 14 Jan 2008 13:59:14 +0000, Dave Gurnell wrote:
> I'm sure I need to convert call-with-transaction to a macro to get  
> access to the position of the call site. However, I'm not sure of the  
> "correct" way of passing the information to insert-into-database. It  
> seems like I have at least two options: continuation marks and  
> parameters, but I don't know the relative merits of which, or which I  
> should choose in this type of situation.
> Can anyone offer any advice (or information on the difference between  
> the two)?

Parameters are just continuation marks indirected through a thread
cell, so that different threads can imperatively mutate the value.

I expect that a continuation mark is sufficient for this problem, but
the extra indirection in a parameter won't normally hurt, and there's a
bit more syntactic support for parameters.

> PS - Transactions may be nested, and I'd like to log the position the  
> outermost call-with-transaction.

The simplest way to implement this is probably to look up the current
value before binding a new one, and keep the old value if there is one.

With continuation marks, you might instead get a list of all bindings
in the current continuation and pick the earliest one, but then you'd
have to be careful about a tail call possibly replacing a value that
you want to keep.


Posted on the users mailing list.