-
Notifications
You must be signed in to change notification settings - Fork 0
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
Swap bitwise with logical operators #4
Comments
Add logical xor and xand too |
This is a good idea; we could maybe take it one step further and combine some of them. |
Ah, I see, kind of like how |
@SheepTester I think types should be able to implement infix operators, like in rust. |
test |
Rust docs say that because and and or short-circuit, they don't have traits for them. However, at least for N, I think I'll make short circuiting a trait-defined thing. This has the benefit of not having to have something like |
@SheepTester Yeah, I'm going to include that in the next implementation of Aardvark; graal has made me mald too much, so I'm probably switching to rust or just vanilla java, at least for now. |
On the other hand, I am a bit conflicted about making |
Hmm, I feel like short circuiting would be rather necessary, especially in cases where it's used in recursion (though I can't think of why it'd be used directly in recursion), unless you're going to make expressions evaluate lazily? 👀 |
I might evaluate pure functions lazily. What do you mean by recursion? |
🙂 (define (any? pred ls)
(and (not (null? ls))
(or (pred (car ls)) (any? pred (cdr ls))))) though admittedly one can just use |
Ah, explains 2020 |
Proposal
The shorter variants should be used for logical operators rather than bitwise operators as the former is used more often, so
&
|
~
are the logical AND, OR, and NOT operators, respectively.&&
||
!
are the bitwise AND, OR, and NOT operators, respectively.^
should also be reserved for exponentiation, so XOR can be something obscure like^^
.Rationale
&
,|
, and~
have roots that might be more recognizable. For example,&
is used in English for "and," and~
is used for negation in math.|
is already used in some syntaxes for multiple options, like regexa|b
.^
is commonly used for exponentiation.In addition, a single character is easier to type (though admittedly the impact of this is negligible), so it should be used for the operator that is used more often.
Duplicating the symbol for bitwise operators would be in line with the bitwise shift operators,
>>
and<<
. Good thing existing languages don't do it the other way around!The text was updated successfully, but these errors were encountered: