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

Change the ternary operator to if..then..else #34

Closed
cshaa opened this issue Jun 17, 2021 · 4 comments
Closed

Change the ternary operator to if..then..else #34

cshaa opened this issue Jun 17, 2021 · 4 comments
Labels
awaiting feedback I'd love to hear feedback from you before I resolve this issue design An issue regarding the user experience implemented This feature is implemented in `develop` and ready for testing
Milestone

Comments

@cshaa
Copy link
Owner

cshaa commented Jun 17, 2021

Many languages, including Python and CoffeeScript, use keywords if and else instead of the ternary operator ?:. This approach is better aligned with the goals of filtrex. In particular, the CoffeeScript version (if a then b else c) is very close to natural language which makes it layman-friendly.

This change is scheduled as a breaking change in v3.0.0. Any discussion is welcome.

@cshaa cshaa changed the title Change the ternary operator to if ... then ... else Change the ternary operator to if..then..else Jun 17, 2021
@cshaa cshaa added awaiting feedback I'd love to hear feedback from you before I resolve this issue design An issue regarding the user experience labels Jun 17, 2021
@cshaa cshaa added this to the v3 milestone Jun 17, 2021
@cshaa cshaa added the implemented This feature is implemented in `develop` and ready for testing label Jun 17, 2021
@cshaa cshaa closed this as completed Jun 17, 2021
@cshaa
Copy link
Owner Author

cshaa commented Jun 23, 2021

This also solves the incorrect precedence of the ternary operator that is present in filtrex v2, see this SO post.

@cshaa
Copy link
Owner Author

cshaa commented Sep 17, 2021

Add back a ? b : c and make it deprecated.

@cshaa cshaa reopened this Sep 17, 2021
@cshaa cshaa removed the implemented This feature is implemented in `develop` and ready for testing label Sep 17, 2021
@cshaa cshaa mentioned this issue Sep 17, 2021
15 tasks
@cshaa cshaa added the implemented This feature is implemented in `develop` and ready for testing label Sep 22, 2021
@cshaa cshaa closed this as completed Sep 22, 2021
@mikefarah
Copy link

Why not support both - personally I prefer ternary operators?

@cshaa
Copy link
Owner Author

cshaa commented Aug 21, 2023

Hey Mike,
Both if-then-else and the ternary operator ?: are currently supported, the latter being marked as deprecated. Since Filtrex is intended to be usable by laymen (ie. the users of applications, not their developers), I think it makes sense to make it familiar for that kind of users. That was my rationale for deprecating the ?: operator, as it is one of the more obscure operators even for programmers – most non-programmers probably never heard of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback I'd love to hear feedback from you before I resolve this issue design An issue regarding the user experience implemented This feature is implemented in `develop` and ready for testing
Projects
None yet
Development

No branches or pull requests

2 participants