You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
Sub-invocations are a way to compose multiple command invocations by passing the output of one command into the switch-value or argument of another command.
Sub-invocations are wrapped in parenthesis ( ... ).
Example passing the result as an argument:
some-cmd (other-cmd)
Example passing the result as a switch-value:
some-cmd --switch (other-cmd)
The sub-invocations form a tree of invocations. For instance, the following example:
a (b (c) (d)) (e (f (g)))
Would form the following tree:
a
b
c
d
e
f
g
The invocations are executed depth-first from left to right. Therefore the execution order of this tree would be:
c
d
b
g
f
e
a
The text was updated successfully, but these errors were encountered:
The only downside is that is it written the opposite way people usually think. If you want to "read a list of objects from a filename, pull out the ones that have a property x greater than four and print it to the screen, you need to write echo (filter "x>4" (readFile filename 'json'))) as opposed to readFile filename 'json' then filter "x>4" then echo. I think that is why the unix | works the way it does. Also the ability to press "up" and get the previous command and just tack more on the end of the previous command if you don't like the output.
But then you loose the flexibility of being able to pass output to different arguments. Which is really nice.
Yeah like you say, the trouble with stdio / piping is that it's a separate channel than the arguments and return value, so it complicates our programming model. That said, it's always possible that we making the piping model work as a syntax variation of sub-invocations, so:
echo (filter "x>4" (cat foo.json)))
could be rewritten as
cat foo.json | filter "x>4" | echo
And it would send the return value into the last unfilled argument, which is implicitly:
Sub-invocations are a way to compose multiple command invocations by passing the output of one command into the
switch-value
orargument
of another command.Sub-invocations are wrapped in parenthesis
( ... )
.Example passing the result as an argument:
Example passing the result as a switch-value:
The sub-invocations form a tree of invocations. For instance, the following example:
Would form the following tree:
The invocations are executed depth-first from left to right. Therefore the execution order of this tree would be:
The text was updated successfully, but these errors were encountered: