On Fri, May 21, 2021 at 4:36 PM Ralph Mellor <ralphdjmel...@gmail.com> wrote:
>
> * Things multiply. If *two* function arguments are junctions, and
>   each junction has, say, three elements, the function is set to be
>   called *six* times.

That should have been *nine* times.

> * The combination has to follow precedence rules. I forget what
>   they are, but the general scheme is that there are two levels
>   and they do what's most natural. This will of course sound very
>   odd so I'll leave it as a thing to explore if you explore this. :)

I just looked in the doc and didn't see discussion of this.

And my investigations began to confuse me.

----

Here's a relatively gentle start focusing on the *operator
precedence* of the *junction literal constructor operators*:
```
say 1 & 2 | 3 & 4; # any(all(1, 2), all(3, 4))
say 1 | 2 & 3 | 4; # any(1, all(2, 3), 4)
```

So the `&` junction op has higher operator precedence than `|`.

This is covered in the doc, starting at:

https://docs.raku.org/language/operators#Junctive_AND_(all)_precedence

The compiler rejects mixing of `|` or `&` infix ops with `^` without
parens to disambiguate, and there is no `none` infix op, so the
above is the only precedence issue to consider for the junction
literal creation infix ops.

----

Next comes combining two or more junctions with other ops / functions.

The focus now is on "precedence" due to combining junctions with
functions (or operators) that aren't themselves junction constructors:
So this isn't about *operator* precedence but instead *junction data*
precedence.

I'll again start with a gentle example, switching to functions (methods)
to avoid confusion with *operator* precedence:

```
say    (1,2).all le (1, 2).one; # all(one(True, True), one(False, True))
say so (1,2).all le (1, 2).one; # False

say    (1,2).one le (1, 2).all; # all(one(True, True), one(False, True))
say so (1,2).one le (1, 2).all; # False
```

This indicates that `one` junctions have higher "precedence" than `all`.

I'm going to stop at this point because I got confused about the exact
"precedence" relationship between the four sorts of junctions and felt
this was potentially a good launch point for others. If no one else does
look into this I may return to this another day but no promises.

--
love, raiph

Reply via email to