YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

!instanceof and !in operators
bonch
#1 Posted : Wednesday, February 20, 2013 10:17:42 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/13/2012(UTC)
Posts: 38

Thanks: 13 times
Was thanked: 1 time(s) in 1 post(s)
Instead of writing:

Code:

if (!(someInstance instanceof someClass)) {}


It would be nice to write:

Code:

if (someInstance !instanceof someClass) {}

// or perhaps

if (someInstance notinstanceof someClass) {}


Same thing for the in operator:

Code:

if (!(someElement in someTable)) {}


Might instead be:

Code:

if (someElement !in someTable)) {}

// or perhaps

if (someElement notin someTable) {}


Thoughts?
JayFoxRox
#2 Posted : Monday, July 15, 2013 8:09:50 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/15/2013(UTC)
Posts: 8
Location: Planet Earth

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
[Late reply]

Not really necessary in my opinion. It would only make the syntax more complicated with no obvious benefit.
I see your point though. And if there was a symbol instead of "instanceof" I would possibly like the inclusion for completion, example:
"x instanceof xClass" -> "x ~ xClass" then it would make sense to have "!~" because it's slightly more similar to "=" and "!=".

But personally I don't think you have to check for "is not instance of". For "in" this probably happens more often but only changing one would be confusing and it's still not necessary. Especially since "!(x in xTable)" is not that unreadable either. Especially with more readable code such as "(x in xTable) == false" which would probably work too.
YourLocalFaxMachine
#3 Posted : Thursday, September 11, 2014 9:22:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/11/2014(UTC)
Posts: 1
Man

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
While I would almost never use this, I would love a nicer syntax for it. It is pretty useless for just about everything, but I like me some pretty syntax.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.112 seconds.