[plt-scheme] Parameters versus continuation marks

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Mon Jan 14 10:10:19 EST 2008

>> 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.

Thank you - that clears up the distinction nicely.

I don't think tail calls would have been a problem here: my existing  
code evaluates the body of call-with-transaction out of tail position  
to create an obvious relationship between the code structure and the  
structure of the transactions in the database. If the programmer  
creates lots of recursion in this kind of situation, they're probably  
putting transactions in the wrong places.

I'll use a parameter, though, and I'll make the call-with-transaction  
macro expand to code that checks for an existing value before  
installing a new one.


-- Dave

Posted on the users mailing list.