GulfOfMexico icon indicating copy to clipboard operation
GulfOfMexico copied to clipboard

Negating Numbers, and Logical Not

Open Magnogen opened this issue 3 years ago • 9 comments

; is a logical not, and traditionally, negating numbers uses a -. It's sort of a similar thing, right?

  • They're both reversible (;;a == a && --a == a)
  • They also both have one to one mapping (a only has one value for -a, and vice versa. a only has one value for ;a, and vice versa)

Why not just remove the -, and make negative 3 be described with ;3?

It also makes a nice winking face ;3

Magnogen avatar May 05 '22 12:05 Magnogen

That's true. We know from JavaScript that operator overloading is terrible (which uses + for adding AND concatenating).

So we must not overload the - operator. Currently it does subtracting AND inverting numbers. This is very confusing. Inverting numbers should be changed to ; I think.

TodePond avatar May 05 '22 12:05 TodePond

Precisely, any symbols that are overloaded should have reasonable logic behind it. And ;3 is reason enough.

Magnogen avatar May 05 '22 15:05 Magnogen

then how do we concatenate strings?

mi2ebi avatar Dec 06 '22 03:12 mi2ebi

We can't use + because that's add. We can't use ++ because that's increment.

I guess we'll have to use +++.

TodePond avatar Dec 06 '22 08:12 TodePond

What about using an &?

const const name = "Lu"!
"Hello, " & name & "!"? // Hello, Lu!

It's kind of makes sense from a reading englishy standpoint, but I'm not sure what your stance is on logical and - is that &&, like JavaScript?

Edit: Just found out that Ada, Modula-3 and Visual Basic all use & for string concatenation, so it would make sense from the user's point of view to use the syntax that they are familiar with. Namely, the syntax of a language that they have never heard of before.

Magnogen avatar Dec 06 '22 15:12 Magnogen

if & is to be used for string concatenation, I'm curious to hear people's thoughts on bitwise and. Are the operators just the words and, or, xor, etc.? Or perhaps to be extra clear that these are for bits only and not for logic, there is a b in front of them as in band, bor, bxor and so on? Other ideas?

Edit: another example of b-prefixing (bfixing?): bnot

jasonflorentino avatar Dec 06 '22 22:12 jasonflorentino

Maybe bitwise and should be 01100001 01101110 01100100?

TodePond avatar Dec 06 '22 22:12 TodePond

So we must not overload the - operator. Currently it does subtracting AND inverting numbers.

Why do we need an operator for subtraction? Isn't subtraction just adding an inverted number?

Joshix-1 avatar Sep 05 '23 20:09 Joshix-1

Good point. And since - wouldn't indicate subtraction, the increment/decrement operators should be and , not --. With that in mind, what should we do with the - character?

ThePython10110 avatar Jul 05 '24 20:07 ThePython10110