-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
consolidate ~ and ! #25435
consolidate ~ and ! #25435
Conversation
base/bitarray.jl
Outdated
end | ||
Cc[end] &= _msk_end(B) | ||
end | ||
return C | ||
end | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be avoided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed. Thanks! :)
(The AV i686 and Travis i686 test failures appear unrelated.) |
People coming from other languages (e.g. Javascript or C++) will often expect EDIT: after thinking more, I no longer think this is such a big deal. Something to consider, though. |
Rebased out conflict. Marking triage for discussion. Best! |
I've decided I like it. |
I really hate the conflation of logical and bitwise operators... Can we claim |
Why? They're the same thing if a Bool is considered one bit. Is it just to help catch bugs? |
Yes. Also, I think most scientists have never heard about bitwise operations, so seeing things like |
We are already very strict about boolean context only accepting I'm not sure that anyone who is fine with |
Rebased out conflicts. Given the perhaps surprising uniformity of support this pull request has received and last week's triage's favor, perhaps triaging again is unnecessary? Best! |
I'm mostly in favor, but I think the strongest objection would be the history of |
Triage is largely in favor. @KristofferC want to make a final plea? |
Everyone on the triage call is in favor of this, but we wanted to give the dissenters to give some input. The general feeling is:
|
I kind of like the idea of replacing As another data point, we use |
I think the biggest risk is with people doing something like |
I've created #25514 to explore a replacement of |
Since we've appropriated |
I think many people against this change will agree even with this statement. As I understand, the question is whether
This is an important argument in favor of this change. While it seems like it easily could have been controversial, I've yet to find a single blog post deriding the Rust developers for this choice (or even a single complaint, anywhere). Of course, Julia is meant to be more approachable than Rust, but many Rust developers will be coming from C where |
Just fwiw, this isn't what it means in C++, and various style guides may mention not to write out |
Another reason we may want the |
I don't think that's a problem. We should probably add |
Small digression: |
There are very few unary operators, and it seems to me none are in the same ballpark of utility as inverting predicates, by a long shot. |
Count me as one of the dissenters. I like to think about interfaces - clear, consistent, reliable interfaces. Most users will be exposed to think of While Also, providing an interface for a very low-level operation like "bitwise not" using one of our precious ASCII operators ( |
I sense enough controversy that we should perhaps leave well enough alone. |
Maybe we should introduce Then Previous suggestions to add |
Is it expected that a I'm personally in favor of the merge of |
Yes, definitely. In theory, the data bits could be any representation at all, like a floating-point number of probability. Here are a couple examples examples of many-valued logic on wikipedia; there's also fuzzy logics with infintely-many values (e.g. probability of truth - which really won't work with From memory I think @JeffreySarnoff might be more familiar with this stuff than me? (Forgive me if I'm mistaken). |
@andyferris, re. #25435 (comment), #25156 and #25180 might interest you. (Edit: Re. "I feel it would be terrible to not know if |
help?> &
search: &
&(x, y)
Bitwise and.
help?> |
search: | |>
|(x, y)
Bitwise or. But I'm not sure what "logical and" and "logical or" functions you would define if that's what you wanted to do. |
Thanks Sacha. It's not different... my position is they're all conflating logical and bitwise (and I feel it would be nice to do something about all of them). |
I don't see that this should pose any difficulty, just add a third column to the truth table:
I was initially very hesitant about this PR, since seeing, e.g., |
My point is that that truth table is not flipping all the bits. What exactly does the bitwise |
Sorry, I suppose my truth table wasn't very clear, as I was mixing some of the implementation details with the definition. Here instead is an executable version of IEEE 1164 standard for full-on 9-value logic (3VL is just the subset X01):
(copied from std_logic_1164.vhd) We can number these however we want, so all that's important is the symbol and the mapping – the bits themselves used to implement this in binary hardware are irrelevant. |
OK, I'm trying to figure out what What you seem to be suggesting here is that we should implement So what the pithy one-liner for describing Sorry everyone for going on (and on) about this - I'm just a little confused what the underlying story is here. |
To clarify why I ❤️ and 😕 @vtjnash's post, I don't really understand it, but I love it.
No worries, I think we're all trying to get clarity here. |
It's the bitflip of In binary logic the bitflip is just:
But if you're making your own hardware following the IEEE 1164 standard, there's 9 possible states for each bit, so the truth table for bitflip is larger:
|
If BTW, I'm not at all against this change, but having a coherent explanation for why it makes sense would be nice 😄 |
I agree that viewing |
Jameson wrote:
I think the the word "bitflip" is being used here to mean the two things I am trying to say are distinct. I would say that this is the truth table for logical negation. I still see the word bitflipping / bitwise NOT as doing something physical to some RAM, cache or register bits (i.e. "binary digits"). The existing methods for |
I am familiar with this stuff. The more frequent uses of a computational logic are to resolve something[s] more quickly than would occur using another approach (e.g. constraint based reasoning) aor to allow easy expression of not-always-simple constructs (e.g. fuzzy reasoning). The first prefers bitwise operations and set valued functions over multibit value representations. In my experience, using one bit (1-of-8 in a byte, etc) per value allows a faster implementation of higher level logic-based operators. Even with fuzzy logic, where the valuations are naturally ordered and easily represented as small integers or floats in (not at all so) 0.. 0.5 (somewhat so) .. 1 (entirely so), it can help to work from distinguished bits and map them to floats as needed. Modal logics require additional structure -- something that our parameters could support very cleanly. |
Triage declines. |
Triage thinks it's a bit too late to put in a change that seems to be this contentious. Closing. |
&
represents both logical and bitwise and. Similarly,|
represents both logical and bitwise or. In contrast,!
and~
separately represent logical and bitwise not. Triage liked the idea of consolidating logical and bitwise not into!
, freeing the precious ASCII territory that is~
for other uses. This pull request implements that consolidation, deprecating~
to!
for bitwise not. Best!