Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

37.1. Multiple Dispatch

Like most object-oriented languages, Perl polymorphically selects the subroutine to invoke in response to a method call. The subroutine is the one belonging to the invoking object’s class. So, a call to $objref->method(@args) invokes CLASSNAME::method, where CLASSNAME is the class into which the $objref object was blessed.

If the class in question doesn’t have a suitable method, then the dispatch procedure searches “upwards” through the various superclasses of the object’s class, looking for an appropriate subroutine. If that search fails, the dispatch procedure searches the complete inheritance hierarchy again, looking for an AUTOLOAD subroutine instead.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial