Skip to content
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

feature request: if function with only "then" in expr #662

Closed
porres opened this issue Jun 19, 2019 · 5 comments
Closed

feature request: if function with only "then" in expr #662

porres opened this issue Jun 19, 2019 · 5 comments

Comments

@porres
Copy link
Contributor

porres commented Jun 19, 2019

the if function in expr needs two arguments, one for "then" and other for "else"

I was hoping for the option of just having the "then" function with only one argument. In this case, the "else" expression would be inexistent and ignored, that is it won't have any output.

@porres
Copy link
Contributor Author

porres commented Jun 19, 2019

maybe a new "ifthen" function?

something:

[expr ifthen($f1 > 0, 1)]

would then only output a "1" if the input is > 0

@umlaeute
Copy link
Contributor

if it doesn't generate any output, then it's no longer an expression.
quoting wikipedia:

An expression in a programming language is a combination of one or more constants, variables, operators, and functions that the programming language interprets [...] and computes to produce ("to return", in a stateful environment) another value.

@danfuzz
Copy link

danfuzz commented Nov 12, 2019

I'd like to petition for this issue to be reopened. I understand that there is a "mathematical purity" to guaranteeing that all expr outlets emit values. However, as a practical matter, it would be very useful to have this functionality, thereby being able to avoid a bunch of boilerplate off of an expr output (e.g. having two outputs, one a boolean, and using that to perform a select).

@porres
Copy link
Contributor Author

porres commented Nov 12, 2019

there's a new issue now: #663

@danfuzz
Copy link

danfuzz commented Nov 13, 2019

Thanks. I saw #663, but I think doing this original issue would be better: What I find myself wanting is, for example, things like a three-output expr where just one of them is possibly not output per incoming execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants