>> Now, regarding Polymorphism and Dynamic Binding.
>>
>> Let me first say that if you are getting all your theoretical knowledge
>> from Wiki, you need to look elsewhere.
>>
>> Secondly, I think you are confusing Dynamic Linking with Dynamic
>> Binding. Linking and Binding are completely different.
>
> What you are talking about only loosely fits the definition of dynamic binding
> in so much as it fits a text book definition.
>
> Really what you have is statically typed dynamic binding
> where all possible functions are defined in the base class
> and the compiler determines static linking of of all functions based
> on the object created.
Firstly, let me guess that you are still in High-School. There is no
such thing as static dynamic binding. This is an example of a
contradiction.
What I refer to as dynamic binding doesn't loosely fit the definition,
it is the definition.
> With true dynamic binding any object can be passed any message even if it
> can not respond to it.
Again you are incorrect, and show that you are ignorant of theory. I'm
being frank here because your treating me like an idiot.
Any time you have language which incorporates complete polymorphism, and
allows the use of pointers, you will be able to send a message to an object
that it may not understand (I.e direct the object to invoke a method which
it, nor its parent classes have implemented).
Both in Java and in REALBasic this is not possible since first, there
are no pointers, and second, because there exists an Object class from which
all objects are descended. All objects in both Java and in REALBasic,
therefore, are necessarily related.
However, this is not the case for Objective C. All objects are not
necessarily related. For example, consider GNU Step Objective C. In
general, objects descend from NSObject. However, it is possible for one to
create one's own Object super class, and have objects inherit from it.
Furthermore, you can use all these objects (regardless of whether or not
they are related), in the same program.
So when I declare:
id anyObjectPtr; (equivalent RB syntax is: dim anyObjectPtr as id)
It is very possible to send an object a message it can't understand.
id is an object pointer data-type in Objective C. However, since all
objects are not necessarily related it is impossible to map any interface to
an object pointed to by an id variable.
However, since in REALBasic and in Java there are no pointers, and all
objects are necessarily related, it is always possible to map some interface
to any object. Therefore, it possible for the compiler to know whether or
not an object can understand a given message.
This, Chris, I believe, is the source of your misunderstanding. Just
because the compiler can map an interface to an object, doesn't mean that
the compiler can map an implementation of the interface to the object.
The compiler can determine whether or not the object can understand the
message, but can not determine the behavior, (the meaning of the message),
for the object once it has received the message. This is an example of
Polymorphism. Sending messages to objects without knowing how they will
behave in response to a given message at compile time.
Dynamic binding simply refers to the binding of an implementation to an
interface, not the binding of an interface to an object. Therefore if I
have:
dim myLifeForm as LifeForm
//assigns some random subclass of Lifeform to myLifeForm
myLifeForm = createRandomLifeForm()
myLifeForm.die() //calls some sort of die.
This is dynamic binding. While the compiler "knows" that myLifeForm can
understand the "die" message (because the compiler "knows" that myLifeForm
has the LifeForm interface), it does not know what "die" message means for
that particular sub-class. The meaning of the "die" message is only
available once the implementation has been bound to the interface. Since
this binding, for the given example, may only occur at runtime, this is an
example of Dynamic Binding.
Now, before you start harping on me saying "Well, C++ uses pointers and
I can't send an object a message it can't understand, so your wrong." Let
me say, that you can indeed send a message to an object which it can't
understand in C++. You just have to know how to do it.
For example, declare an integer, use it as a pointer, point it to some
object, then send that object some message it can't understand. Voila.
Adam.
-
Definitely not a idiot
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|