[elixir-core:10473] Proposal: Kernel.then/3

2021-10-08 Thread 'Damir' via elixir-lang-core
Often I have a function that I want to apply to a pipeline conditionally. I'm forced not to either write a "maybe_do_x" function or use an inline check with then/2. Now that we have then/2, I'm thinking it might be nice to have then/3 so that we don't need "maybe_" functions anymore, improving

Re: [elixir-core:10473] Proposal: Kernel.then/3

2021-10-08 Thread Allen Madsen
No opinion on whether this function exists or not. But, if it did, I think the second argument should be a function, so that conditionality can depend on a property of the first argument. Allen Madsen http://www.allenmadsen.com On Fri, Oct 8, 2021 at 6:59 AM 'Damir' via elixir-lang-core < elixir

Re: [elixir-core:10474] Proposal: Kernel.then/3

2021-10-08 Thread Paul Clegg
I think this has been brought up a few times and not sure there's a great need for it. It can't (shouldn't) happen _that_ many times, because if you're not going to do something with the result of a function the chances are you should be bothering to do_something() to the function anyway. And eve

Re: [elixir-core:10476] Proposal: Kernel.then/3

2021-10-08 Thread 'Damir' via elixir-lang-core
Hi! Thanks for the elaborate response! > You have to write "write_y()" function anyway, so create a version that has a no-op version that simply returns the argument: Sometime write_y is already there and then you need to write a wrapper function. Also I really try to avoid putting a boolean i

Re: [elixir-core:10476] Proposal: Kernel.then/3

2021-10-08 Thread José Valim
I don't believe we should necessarily be leading people to encode more logic into pipelines. For example, sometimes the value that is in the conditional comes from the pipeline, other times it is simpler to pattern match with "case" or "with", etc. Or just a plain old conditional. It should also be