On Tue, Jul 05, 2005 at 01:24:38AM +0100, Fergal Daly wrote:
> There's an easy way to see what's "accptable" and what's not and what
> exactly this level equality means. Consider the following code
> template:
>
> #######
> # lots of stuff doing anything you like including
> # setting global variables
>
> my $value = do {
> # these can access any globals etc
> my $a = one_way();
> my $b = another_way();
> is_very_deeply($a, $b) || die "they're distinuguishable";
>
> # choose one of $a and $b at random
> rand(2) < 1 ? $a : $b;
> };
>
> print test($value);
> #######
my $x = [];
sub one_way = { $x }
sub another_way = { [] }
sub test = { $_[0] == $x }
I don't think this breaks your rules, but see below.
> Assuming:
>
> 1 nothing looks at ref addrs (they may compare refs addrs, they can
> even store them in variables for comparison later on as long as
> nothing depnds on the actual value, just it's value in comparison to
> other ref addrs).
check
> 2 - one_way() and another_way() don't have side effects ***
check
> Then test() cannot tell whether it got $a or $b. That is, any attempt
> by one_way() or another_way() to communicate with test() will be
> caught by is_very_deeply().
>
> In this case it's clear that
>
> sub test
> {
> $_[0] == $a
> }
>
> is not acceptable because only one of $a and $b ever makes it back
> into program flow and at that point it's got a new name.
I don't understand what you're saying here. As you've written it, $a in
test is unrelated to the $a and $b in your do statement above, so your
test will return false in both cases. Is that all you meant?
Anyway, I don't think you're rejecting my test. If you do reject my
test, tell me which assumption I violated.
Andrew