realbasic-betas.mbox
[Top] [All Lists]

Re: "Is" operator questions

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: "Is" operator questions
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Fri, 17 Jan 2003 07:45:53 -0800
At 10:15 PM -0800 1/16/03, Will Leshner wrote:

Is not the case that you can now overload operator equals? If that is the case then you cannot do:

if obj1 = obj2 then

without potentially invoking an operator equals. In that case you might want to be able to override the override, which would explain the necessity of the 'Is' operator.

Yes, that's right exactly. If you want to be sure you're testing whether two variables refer to the same *object*, then use "Is". If you want to test whether the one or two objects they refer to represent the same value, then you may use "=". Currently, for all built-in classes, these do exactly the same thing. But it's possible that in the future, we'll overload '=' for some classes. Likely candidates (just my personal opinion):

        Date
        TextEncoding
        Variant
        maybe FolderItem

You might want to start using "Is" now in cases like these, so that the behavior of your code doesn't change in the future if '=' is overridden.

Cheers,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout           REAL Software, Inc.                |
|    joe at realsoftware dot com       http://www.realsoftware.com        |
`------------------------------------------------------------------'

---
A searchable archive of this list is available at:
<http://support.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:realbasic-betas-off at lists dot realsoftware dot com>

Subscribe to the digest:
<mailto:realbasic-betas-digest at lists dot realsoftware dot com>
.


<Prev in Thread] Current Thread [Next in Thread>