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

NOT operator #1

Open
grimblefritz opened this issue May 22, 2015 · 5 comments
Open

NOT operator #1

grimblefritz opened this issue May 22, 2015 · 5 comments

Comments

@grimblefritz
Copy link

While the complement "~(expression)" feature is good, it is syntactically ugly - especially in more complex queries. I would like to see a NOT operator as it would make expressions simpler to write and read. I think the best choice is to use the bang (!) to negate the following expression:

!name
name!=value

This would allow expressions such as:

!compute && type!=admin && mem=64

rather than:

~(compute || type=admin) && mem=64

As I said earlier, I believe the benefit becomes more apparent as the complexity of the query increases.

@chu11
Copy link
Member

chu11 commented May 22, 2015

I will admit that some of the tokens are non-optimal. They were selected based on what characters & symbols users were already commonly using in genders. Although I cannot recall why, some users were using a ! sign already for some purpose.

But perhaps this should be revisited.

@grimblefritz
Copy link
Author

Well... that could be alleviated by allowing quoted values:

name="value"

but that's a whole 'nother can of worms! (And even more overhead in parsing.)

Perhaps a --compat flag that would use the old-style parsing?

@wlschwartz
Copy link

Thanks, Grimble! This and your other submissions all look like strong suggestions. Let's see it happen!

@elstak
Copy link

elstak commented Jun 1, 2015

Why using the Polish notation only for the negation operator? I can understand it may be simple to implement, but it makes not consistent with the rest of infix operators.

@grimblefritz
Copy link
Author

My usage of genders is based primarily on nodeattr. I don't find the proposed use of "!" to be inconsistent with shell conventions. Certainly a "not equal" operator is common to most languages, and !expression is equivalent to "not expression" and also "if ! [ test ]" in shell. Perhaps it is inconsistent with a textbook definition of infix operators, but it seems very consistent with the typical callers of nodeattr.

Also, I think simple is in keeping with the design objectives of genders.

BenCasses added a commit that referenced this issue Jul 16, 2015
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

4 participants