Skip to content
Prev 60673 / 63421 Next

Pipe operator status, placeholders?

On 4/19/22 8:22 PM, Duncan Murdoch wrote:
As long as the search for placeholders is linear in the size of the 
total expression, I suspect that this would will be quite fast.? It 
might be a bit tricky to make sure that each sub-expression is searched 
only once, if there are nested pipes.
If you have something like x |> f(_, y |> g(_)), then you could make a 
rule, such as: when the top-level pipe searches for a placeholder in its 
RHS, it ignores the RHS of any nested pipe operator that it finds.

Interestingly, this happens automatically.? When the top-level pipe 
operator searches its RHS for the placeholder, it would see `f(_ , 
g(y))`.? Any nested pipe in the RHS would already have consumed its own 
placeholder and been transformed into a pipeless expression.

However, the top-level pipe would search the expression `g(y)` for a 
placeholder, which means that the expression gets searched twice.
Yeah, this makes sense.? If you allow the placeholder to occur twice, 
you can't just substitute the expression, because then you could 
evaluate it twice.? Then you have to implement lazy evaluation, which 
the lambda function syntax `x |> (\(d) ...)()` already does.

take care,

-BenRI