PyHP-pph / PyHP_pph

This repository serves as a centre for collaboration on the PyHP++# language. It will also include a functioning interpreter and compiler for PyHP++# once the standard is finalised.
https://www.reddit.com/r/PyHP_pph/
GNU Affero General Public License v3.0
23 stars 3 forks source link

Suggestion for not equal. #5

Open PumpkinSeed opened 7 years ago

PumpkinSeed commented 7 years ago

Javascript using == as comparison operators and === as strict comparison operators. Can this new awesome lang using ==== for not equal?

For example:

if (1 ==== 2) {
  // true or how the if evaulate it 
}
Boscillator commented 7 years ago

The real reason === is bad, is that == still works, except it can get you into real problems in edge cases. == and === still should do something in PyHP++#

I propose that == returns a the string "the values $a and $b are the same" if they are and "the values $a and $b are not the same" if they are not. (with $a and $b substituted for the correct value). That way (do to type contortion), the expression will always evaluate true.

=== should do something equally ludicrous.

ghost commented 7 years ago

Perhaps === should return the difference between the two. -2 === 5 would be 8, 3 === -12 would be 16, etc.

ghost commented 7 years ago

But then how do we actually check if two values are equal if neither == nor === does that?

Kampfkarren commented 7 years ago

equals(val1, val2) perhaps?

Kampfkarren commented 7 years ago

Although another problem arises if you override the functionality of ==, the original source code will end up being invalid.

Boscillator commented 7 years ago

That's true. Maybe we should keep == normal.

ghost commented 7 years ago

I've created operators branch, I will add suggestions here to operators.md.

ghost commented 7 years ago

What do you think of this?

Kampfkarren commented 7 years ago

Not too sure about it. I forget who said it, but I remember someone here saying something along the lines of "We want to make a bad language because it has all these different languages, not a bad language with elements from the languages thrown in. "

ghost commented 7 years ago

That's true, but all of the inspiration languages use ==. PyHP++# is intended to be satirical and strange to work with, and so having only == would be against the 'feel' of the language. In a way it's like the inversion of False and True.