On Monday, 9 June 2014 04:44:22 UTC+1, Chris Angelico wrote:
> This could be solved, though, by having a completely different symbol
> that means "the thing on my left is actually the first positional
> parameter in the function call on my right", such as in your example:
>
> > plus(1, 2) | divide(2)
>
> This would be absolutely identical to:
>
> divide(plus(1, 2), 2)
>
> Maybe you could even make it so that:
>
> plus(1, 2) x=| divide(y=2)
>
> is equivalent to
>
> divide(x=plus(1, 2), y=2)
>
> for the sake of consistency, and to allow the pipeline to inject
> something someplace other than the first argument.
>
> I'm not sure whether it'd be as useful in practice, though. It would
> depend partly on the exact syntax used. Obviously the pipe itself
> can't be used as it already means bitwise or, and this needs to be
> really REALLY clear about what's going on. But a data-flow notation
> would be of value in theory, at least.

## Advertising

Perhaps a pipeline symbol plus an insertion marker would work better in Python:
plus(1, 2) ~ divide(x=^, y=2)
f.readlines() ~ map(int, ^) ~ min(^, key=lambda n: n % 10).str() ~
base64.b64encode(^, b'?-') ~ print(^)
Stdio.read_file("foo.jpg") ~ Image.JPEG_decode(^).autocrop().rotate(0.5).grey()
~ Image.PNG_encode(^) ~ Stdio.write_file("foo.png", ^)
--
https://mail.python.org/mailman/listinfo/python-list