• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Function calling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Function calling
      • From: Bob Ippolito <email@hidden>
References: 
 >Function calling (From: "Theodore H. Smith" <email@hidden>)
 >Re: Function calling (From: Ondra Cada <email@hidden>)

  • Prev by Date: List of QuickTime File Types
  • Next by Date: Re: Function calling
  • Previous by thread: Re: Function calling
  • Next by thread: Re: Function calling
  • Index(es):
    • Date
    • Thread