Luke Palmer wrote: > Of course, this was introduced for a reason: > > sub min($x,$y) { > $x <= $y ?? $x !! $y > } > sub min2($x, $y) { > if $x <= $y { return $x } > if $x > $y { return $y } > } > > In the presence of junctions, these two functions are not equivalent. > In fact, it is possible that both or neither of the conditionals > succeed in min2(), meaning you could change the order of the if > statements and it would change the behavior. This is wacky stuff, so > we said that you have to be aware that you're using a junction for > "safety".
Hmm... min2 behaves differently from min because the > function doesn't act as the negation of the <= function when dealing with junctions. As you say, wacky stuff. > But now I'm convinced, but I've failed to convince anyone else, that > the behavior's being wacky doesn't mean that it should be declared, > but that the behavior is just plain wrong. I figure that if something > says it's totally ordered (which junctions do simply by being allowed > arguments to the <= function), both of these functions should always > be the same. The fact is that junctions are not totally ordered, and > they shouldn't pretend that they are. If junctions say that they're totally ordered by virtue of being usable in the <= function, and junctions shouldn't say that they're totally ordered, it follows that they shouldn't be usable in the <= function. Since one of the main purposes of junctions is to be usable in the <= function, this constitutes a problem. IMHO, the fallacy is the claim that something is totally ordered simply by being allowed arguments to the <= function. Total ordering is achieved by being allowed arguments to a <=> function that always returns one of -1, 0, or +1. When a junction is fed into a <=> function, it will not always return one of -1, 0, or +1; it could instead return a junction of -1's, 0's, and/or +1's (or maybe it should fail?). > The other thing that is deeply disturbing to me, but apparently not to > many other people, is that I could have a working, well-typed program > with explicit annotations. I could remove those annotations and the > program would stop working! In the literature, the fact that a > program is well-typed has nothing to do with the annotations in the > program; they're there for redundancy, so they can catch you more > easily when you write a poorly-typed program. But in order to use > junctions, using and not using annotations can both produce well-typed > programs, *and those programs will be different*. I'm not following; could you give an example? -- Jonathan "Dataweaver" Lang