DX6 #isKindOf: oddness

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

DX6 #isKindOf: oddness

Don Rylander-3
In Professional 6.02, #isKindOf: doesn't seem to work as advertised, whereas
#includesBehavior: does.  Try

DialogView isKindOf: View. "returns false for me"
DialogView includesBehavior: View "returns true"

I didn't test it exhaustively, but it only seems to work if the
candidateClass is Object.

Don


Reply | Threaded
Open this post in threaded view
|

Re: DX6 #isKindOf: oddness

Matt-2
Don Rylander schrieb:

> In Professional 6.02, #isKindOf: doesn't seem to work as advertised, whereas
> #includesBehavior: does.  Try
>
> DialogView isKindOf: View. "returns false for me"
> DialogView includesBehavior: View "returns true"
>
> I didn't test it exhaustively, but it only seems to work if the
> candidateClass is Object.
>
> Don

What is advertised is:
"Answer whether the receiver is an instance of the argument,
candidateClass,
        or one of its subclasses....."
You send #isKindOf: to the class DialogView and not to one of it's
instances.
DialogView new isKindOf: View. "returns true for me"

Cheers
Matt


Reply | Threaded
Open this post in threaded view
|

Re: DX6 #isKindOf: oddness

Ian Bartholomew-21
In reply to this post by Don Rylander-3
Don,

> In Professional 6.02, #isKindOf: doesn't seem to work as advertised, whereas
> #includesBehavior: does.  Try
>
> DialogView isKindOf: View. "returns false for me"

I've got the T-Shirt for that one :-)

The comment for #isKindOf: starts

"Answer whether the receiver is an instance of the argument,
candidateClass, or one of its subclasses."

Note the "instance". So

DialogView  new isKindOf: View "answers true"


Note that

DialogView isKindOf: View class

will also answer true, see the #isKindOf: method for why.

--
Ian

Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: DX6 #isKindOf: oddness

Don Rylander-3
In reply to this post by Matt-2
Matthias,
> You send #isKindOf: to the class DialogView and not to one of it's
> instances.
> DialogView new isKindOf: View. "returns true for me"

Doh!  Now that's a dumb mistake (at least I should know better).

Thanks Matthias,

Don


Reply | Threaded
Open this post in threaded view
|

Re: DX6 #isKindOf: oddness

Don Rylander-3
In reply to this post by Ian Bartholomew-21
Ian,
"Ian Bartholomew" <[hidden email]> wrote in message
news:[hidden email]...
[...]
> I've got the T-Shirt for that one :-)
I hope they're not expensive.  I think I've obligated myself to buy a couple
related ones this week, too.

[...]
> DialogView isKindOf: View class
That's what I was really trying to do.

Thanks, Ian.

Don


>
> will also answer true, see the #isKindOf: method for why.
>
> --
> Ian
>
> Use the Reply-To address to contact me (limited validity).
> Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: DX6 #isKindOf: oddness

Thomas Koschate-4
Don Rylander wrote:

> [...]
>> DialogView isKindOf: View class
> That's what I was really trying to do.

Of course, one might ask the question, "Is this what I should be doing?"

Most of the places where I've seen #isKindOf: being used have been to
differentiate behavior based on the class of the receiver, when, in
fact, polymorphism and/or double-dispatch would have given a better
solution, being more robust and easily extensible.