Re: Function calling
Re: Function calling
- Subject: Re: Function calling
- From: Bob Ippolito <email@hidden>
- Date: Wed, 25 May 2005 17:57:22 -0700
On May 25, 2005, at 5:40 PM, Thomas Davie wrote:
Here, item is actually an "id". And so we can't know what type of
object it is, or whether a childAtIndex method actually exists.
So, my question is, how does this work?
Properly :)
We (nor compiler) need to know nothing. The object knows. That's
called "encapsulation" and "polymorphism".
Encapsulation yes, polymorphism no... The compiler can know about
polymorphic types e.g. here's a Haskell type signature:
map :: (a -> b) -> [a] -> [b]
The function map can take any type as a first argument, as long as
it's some kind of function. It can take a list as a second
arcument, as long as the list contains the items of the same type
as the argument type of the function we passed in. It returns a
list, ant that list contains only items of the return type of the
function passed in.
Th compiler knows about the polymorphism and can check that it's
rules are never violated.
Just because the compiler is dumb doesn't mean the language doesn't
support polymorphism. It certainly exists in Objective-C.
-bob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden