PyHP_pph icon indicating copy to clipboard operation
PyHP_pph copied to clipboard

Suggestion for not equal.

Open PumpkinSeed opened this issue 8 years ago • 10 comments

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 
}

PumpkinSeed avatar Jun 16 '17 15:06 PumpkinSeed

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.

Boscillator avatar Jun 16 '17 15:06 Boscillator

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

ghost avatar Jun 16 '17 20:06 ghost

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

ghost avatar Jun 16 '17 20:06 ghost

equals(val1, val2) perhaps?

Kampfkarren avatar Jun 17 '17 21:06 Kampfkarren

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

Kampfkarren avatar Jun 17 '17 21:06 Kampfkarren

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

Boscillator avatar Jun 17 '17 21:06 Boscillator

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

ghost avatar Jun 19 '17 17:06 ghost

What do you think of this?

ghost avatar Jun 19 '17 17:06 ghost

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. "

Kampfkarren avatar Jun 19 '17 19:06 Kampfkarren

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.

ghost avatar Jun 20 '17 08:06 ghost