Luke Palmer wrote:
> Whatever solution we end up with for Junctions, Larry wants it to
> support this:
>
>     if $x == 1 | 2 | 3 {...}
>
> And I'm almost sure that I agree with him.  It's too bad, because
> except for that little "detail", fmap was looking pretty darn nice for
> junctions.

Not really.  If I read the fmap proposal correctly,

  if any($x, $y, $z) »==« any(1, 2, 3) {...}

would do the same thing as

  if $x == 1 || $y == 2 || $z == 3 {...}

...which fails to dwim.  Not to mention

  if all($x, $y, $z) »==« any(1, 2, 3) {...}
  if any($x, $y, $z) »~~« all($a, $b, $c) {...}

...which ought to work like

  if ($x == 1 || $x == 2 || $x == 3)
  && ($y == 1 || $y == 2 || $y == 3)
  && ($z == 1 || $z == 2 || $z == 3)
  {...}
  if ($x ~~ $a && $x ~~ $b && $x ~~ $c)
  || ($y ~~ $a && $y ~~ $b && $y ~~ $c)
  || ($z ~~ $a && $z ~~ $b && $z ~~ $c)
  {...}

And then there's the (minor) ugliness of having to remember to include
hyperspanners (» and/or «) whenever you want to evaluate junctions.

--

Side note: "any(1, 2, 3)" is indistinguishable from "one(1, 2, 3)",
because the values 1, 2, and 3 are mutually exclusive.  People often
use the inclusive disjunction when they mean the exclusive one, and
get away with it only because the values that they're dealing with are
mutually exclusive.  Another issue is that one-junctions conceptually
represent a single value at a time - though which one is unknowable -
whereas any-junctions can also represent several values at once,
all-junctions usually do so, and none-junctions can even represent no
values.  Conceptually, one-junctions are scalar-like, while the other
kinds of junctions are list-like; so one ought to think of "$a ~~
one(@set)" as matching a scalar to a scalar, whereas "$a ~~ any(@set)"
would be matching a scalar to a list (and thus would more properly be
"$a ~~« any(@set)"). But because the distinction between inclusive and
exclusive disjunctions is moot when the component choices are already
mutually exclusive, there's an advantage to any-junctions and
one-junctions behaving in the same way.

--
Jonathan "Dataweaver" Lang

Reply via email to