Re: C question for you old guys ;-)
Re: C question for you old guys ;-)
- Subject: Re: C question for you old guys ;-)
- From: Sailor Quasar <email@hidden>
- Date: Wed, 11 Jun 2003 12:37:25 -0400
On Wednesday, June 11, 2003, at 11:26 AM, David Bishop wrote:
In context, the meaning is obvious.
if (a is b) { foo; }
while (a is b) {bar;}
What you are pointing out is exactly why some people like replacing ==
with
is, so that you *don't* mix up "is" from "is equal".
I didn't want to get involved in this thread, but I have to disagree.
"is" could have at least two meanings in an Objc environment:
given "if (a is b)", where a and b are id's,
is a the same object as b? (i.e. same pointer)
does a contain the same value as b? (i.e. two separate NSNumbers with
the same stored value)
Further, "if ((a is b))" would read to me as "if ((a = b) == true)",
given the normal use of doubled parenthesis in a C environment (supress
compiler warnings about possible unwanted assignment when it's on
purpose. I write "if ((self = [super init]))" all the time in objc).
Confusion mounts.
For any of you who have ever worked in the horrible disaster that is VB
.NET, it has = as a general comparison operator and Is as an object
equality operator. You can't compare to Nothing (VB equivelant of nil)
with =, only Is, but using = invokes the IComparable protocol and...
anyway, trying to figure out which one to use, nevermind remembering
that == caused freaky syntax errors, had a way of blowing my mind.
I'm all for the intelligent and considered use of macros to simplify
the readability of code. But personally, I don't think that "#define is
==" is such a use. (Major IMHO here).
-- Sailor Quasar, just another player in The World
"Come with me in the twilight of the summer night for awhile"
Email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.