On Fri, May 21, 2021 at 9:39 PM Joseph Brenner <doom...@gmail.com> wrote:
>
> Thanks, yes the actual result is certainly consistent with the
> junction applied at the top level, and not internally, which is
> what I was expecting.

A junction passed as an argument is immediately expanded unless
a function is specifically coded to handle junctions for that argument.

That is a large part of the beauty of the junction design. All functions
(and thus all operators) automatically get a very useful and powerful
junctional behavior for free. They don't even know junctions exist.

> Is there actually no way to pass a junction in to a function so that
> it can be used later in an internal smartmach?

(This is Raku. The safer bet is to presume there's a way and you
just don't know what it is.)

My guess is that < 0.1% of Raku functions have the additional
code you're suggesting. But it's easy enough. I haven't tested
this but something like should work, doing whatever it is you
think makes sense for the ... bits:

```
sub find (Junction :$exclude, |rest) {
  ...
  ... File::find ..., |rest
  ...
}
```

Explicitly catching the `Junction` type in the signature means the
"autothreading" doesn't happen.

> That's been my rough impression of what junctions are for,
> a way to have a compound value that's treated as a single
> one until it's used.

If Raku did *not* expand junctions by default, then functions
would have to explicitly decide when to "use" them, which
means all of them would have to A) know about junctions,
B) include explicit code to handle them. It would be awful!

--
love, raiph

Reply via email to