(I didn't think to respond to this until I saw a later response from dlux.)


Ken Fox wrote:
> 
>   try transaction {
>      ...
>   }
> 
> That's a really interesting extension to exceptions -- code that has
> no side-effects unless it finishes. 

Well, maybe transaction-enabling variables could help one achieve
this, but it would not be an automatic result.

I mean, in

        my $x = 0;

        sub side {
                $x = 1;
        }

        trans {
                side();
                die;
        };

        print "x=$x\n"; # should print 1, yes?
        # side-effect achieved, despite having occurred inside
        # a trans block.

I don't believe $x should have been transaction-enabled here.
That would just be a major problem.
No, the semantics of trans should be much more constrained.
Tacking it onto the mechanics of C<local> seems much more
straightforward, I think.

        $x = 0;

        sub side {
                $x = 1;
        }

        trans {
                local $x;
                side();
                print "x=$x\n"; # should print 1
                die;
        }

        print "x=$x\n"; # should print 0

Personally, I'd rather see transaction-enabling requested on
a per-variable basis.

-- 
John Porter

        We're building the house of the future together.

Reply via email to