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

the name 'xor' can be misleading #18

Open
vvvvalvalval opened this issue Dec 7, 2016 · 5 comments
Open

the name 'xor' can be misleading #18

vvvvalvalval opened this issue Dec 7, 2016 · 5 comments

Comments

@vvvvalvalval
Copy link

vvvvalvalval commented Dec 7, 2016

Small nitpick on the 'xor' name:

In this library, the semantics of xor is "matches exactly one spec".

However, the commonly accepted meaning of the XOR operator (in math and CompSci) is boolean addition, which actually means "an odd number of those are true" (not "exactly one of those is true", except for the 2-arity case of course).

I think one-of would be a better name. If it's too late, maybe document it?

@gfredericks
Copy link
Owner

this is a good criticism.

one thing it's not too late to do is make an alias and deprecate the old name.

Not sure how I feel about one-of, it might be easy to interpret the same way as s/or. exactly-one-of is pretty long though.

@vvvvalvalval
Copy link
Author

Let's not optimize prematurely for concision :) (not until experience shows people use it a lot, at which point we can always think of a shorter alias)

That be said, I can suggest one-match as another shorter name

@gfredericks
Copy link
Owner

I just remembered that it should be fine to break things as long as clojure.spec is still breaking things. So I'll just rename it.

@muhuk
Copy link

muhuk commented Jan 8, 2017

I'd read one-of might match one or more.

How about just-one ?

@aaroncummings
Copy link

I think the term 'one-hot' (from logic design) might best represent the intent. See https://en.wikipedia.org/wiki/One-hot for the background.

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