Re: Function calling
Re: Function calling
- Subject: Re: Function calling
- From: Thomas Davie <email@hidden>
- Date: Thu, 26 May 2005 01:40:24 +0100
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.
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