-
Notifications
You must be signed in to change notification settings - Fork 685
exec and eval operators #3356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exec and eval operators #3356
Conversation
This sounds interesting. Regarding In relation to In this case, it would be even nicer to allow of a special input keyword. following your example, something like
where Not sure about the feasibility to use |
The primary use case of of
|
This alternative proposal is very neat, but as you say '-' won't work due to the groovy parser. Alternatives could be:
I think both would be harder to implement than an operator such as |
I think
Using
I think it's worth to give it a try |
I agree it is generic, but it is hard to think of a less generic name. Maybe Channel.of(['A', 1], ['B', 3], ['C', 4]) \
| branch { a: it[0] == 'A'; other: true } \
| chain { a.combine(other) } \
| view
How does this sound for an implementation approach:
|
it sounds like a plan! |
New operators
eval
andexec
This PR is intended to start a discussion about the potential usefulness of the proposed operators, but also provides an implmentation that could be built upon.
These operators are non-standard in the sense that they don't transform the contents of a channel but provide a tool for programming with channels, similarly to
set
. These were inspired based on discussion at #3243, and are somewhat relevant to #3272.The main advantage is that they facilitate piping/chaining and result in fewer intermediatate channel variables being assigned.
eval
Evaluate a closure with the Channel or Multi-channel (as output by branch, multimap or processes with multiple outputs) source as delegate and return the result. In the case of named multi-channel sources the name can be used directly. This works similarly to Groovy's
with()
function.exec
Execute a process using the source channel as first input. Multi-channel inputs are unpacked into subsequent inputs, following by any arguments given to the operator.
Examples
All examples use the following processes:
All examples output the same result_ch:
Object Orientated Style (no piping)
Without
eval
andexec
With
eval
andexec
Piping Style
Without
eval
andexec
With
eval
andexec