chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] Fix #1227 and simplify "parameterize" macro a bit


From: Peter Bex
Subject: [Chicken-hackers] Fix #1227 and simplify "parameterize" macro a bit
Date: Sat, 23 Jan 2016 17:35:54 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi hackers,

Attached is a fix for #1227: when (parameterize) is used with parameters
that have a "guard" procedure associated with them, and one of the guards
raises an exception, the parameters that had already been converted by
their respective guards would not get reset properly.

The fix is as I mentioned in the ticket: We change the semantics of
parameter object procedures a bit.  Instead of accepting a "hidden"
extra argument which indicates the guard procedure should be skipped,
we add another argument which indicates that the parameter should not
be set.

This allows us to call just the guards, one by one, and use "let" to
bind these to temporaries.  After having called all the guards, we
then the parameter object procedures again, this time bypassing the
guards and asking them to set the values to the temporaries.

In between, we ask the parameters for their current value, so that we
can remember them.  This can then be restored when leaving the dynamic
extent of the parameterized body, and flipped back again when entering,
at which time we skip application of the guards.

I didn't expect this, but it actually fixes the "ordering bug" as well,
because we simply set the parameters to their original values we saved
earlier!

This code is a bit tricky; I found it difficult to work out in my head
how "swap!" works, so I decided to simplify the code by using different
procedures for dynamic-wind's "pre" and "post" arguments.  The "post"
one is simple, and it becomes clearer how the "mode" stuff works by
pulling it apart like this.  Even though the two procedures differ,
the code is actually less LOCs than the original because we can drop a
renamed procedure name and the code goes a bit to the left, which allows
us to put some things on a single line that arguably belong on one line.

This simplification is in the second patch.  It is purely optional: the
first patch completely fixes the bug.  I'll leave it to the reviewer to
decide whether the second patch really does simplify things.

These patches apply to both master and chicken-5.

Cheers,
Peter

Attachment: 0001-Fix-nonlocal-exit-handling-in-parameterize.patch
Description: Text Data

Attachment: 0002-Simplify-parameterize-expansion.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]