operators !=

Aaron J. Seigo aseigo at kde.org
Mon Aug 25 10:01:22 UTC 2014


On Monday, August 25, 2014 11.13:02 Samuel Gaist wrote:
> Since it should be a boolean operator, I'd rather go for b.
> It will probably avoid lots of questioning and "strange logic" looking code

As long as we are OK with this:

	var x = 3;
	x = 3;
	(x, var y) = someListOrTuple;

being syntactically correct while this is not:

	var x != 3; // doesn't work; unsurprising
	x != 3; // works, but also unsurprising
	x != 4; // fails, but unlike = would not throw an error
	(x, var y) != someListOrTuple; // doesn't work. why?

It's the combination of assignment and equality that causes this inconsistency 
with !=. Either the language can be fully consistent internally ("!= is the 
negation of =") or it can conform to current developer expectations.

Draft documentation for option (b):

====
!= is a comparison operator that checks for non-equality and always returns a 
boolean value as a result. Examples:

	var x = 3;
	x != 4; // correct, returns true
	x != 3; // incorrect, returns false

Note: Unlike the equality operator =, != may not be used in conjunction with 
variable assignment.
====

This does make the language a bit simpler, so it has that going for it. I'll 
sit on this one for a few more days to allow the ideas to settle a bit more in 
my own head and give others an opportunity to weigh in as well ...

-- 
Aaron J. Seigo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://kde.org/pipermail/funq-devel/attachments/20140825/d008669c/attachment.sig>


More information about the Funq-devel mailing list