Jon Lang wrote:
[proposal that conditional statements should collapse junctions]
$x = +1 | -1;
if $x > 0 { say "$x is positive." }
else { say "$x is negative." }
I suspect that both codeblocks would be executed; but within the first
block, $x == +1, and within the second codeblock, $x == -1.
The problem I see with this (other than implementation issues) is that
it would lead to unintuitive behavior in some cases:
my $x = one(10,20);
if $x > 15 {
# here, $x collapsed to "20"
if $x > 5 { say "$x > 5" } else { say "not $x > 5" }
}
if $x > 5 { say "$x > 5" } else { say "not $x > 5" }
Some people might be surprised if the two tests of "$x > 5" result in
two different results.
I don't think that there is any single semantics that won't cause
surprises (unintuitive behavior) in some cases. So I'd vote for going
with simple semantics that are easy to explain -- that is, don't attempt
implicit junctional collapse. Provide operators to collapse when needed,
but don't attempt to be too clever.