Re: C question for you old guys ;-)
Re: C question for you old guys ;-)
- Subject: Re: C question for you old guys ;-)
- From: Glenn Andreas <email@hidden>
- Date: Wed, 11 Jun 2003 14:24:14 -0500
At 10:50 AM -0400 6/11/03, Robert Palmer Jr wrote:
Hello all,
so as someone who has read most of this thread, but missed some of
the original, I would offer another thought (sorry to keep this
going, but it struck me this morning).
what does:
"a is b" mean?
Seriously if I hadn't been told, this would NOT be obvious. Does
this mean "a IS EQUAL to b" (assignment) or "IS a equal to b"
(comparison).
In Python, "is" means "is the same object" which is different from
"=" which means "equivalent value"
So
if 5 == 5: print "OK"
if 5 is 5: print "OK"
if "abc" == "a" + "b" + "c": print "OK"
all print "OK"
but
if "abc" is "a" + "b" + "c": print "NOT OK"
doen't print anything.
With objects in Cocoa, "==" means "is the same bitwise pattern"
(i.e., the same object) and the method "isEqualTo:" is used for
"equivalent value".
Of course in C++, "==" can mean just about anything, from the same
bit-level pattern to "equiavlent value" or whatever some sicko
decides it should mean (which may have nothing to do with the concept
of "is"ness, just like "<<" with iostreams has nothing to do with
bit-shifting).
So basically, depending on the context of it's usage and the
background of the person reading code, "is" may not have the same
meaning as "==" would/should.
though I think we can all agree that this is far less an abomination than :
#define IF if (
#define THEN )
#define ELSE else
#define BEGIN {
#define END }
etc...
(which I still remember being touted as a "great" thing to help
people move from Pascal to C in a Byte article years back).
Glenn Andreas email@hidden
Author of Macintosh games: Theldrow 2.3, Blobbo 1.0.2, Cythera 1.0.2
Be good, and you will be lonesome
_______________________________________________
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.