Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!nerds-end From: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: Help needed with function pointer examples Date: Tue, 17 Jan 2012 16:28:38 +0100 Organization: Compilers Central Lines: 22 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <12-01-034@comp.compilers> References: <12-01-006@comp.compilers> <12-01-026@comp.compilers> <12-01-029@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1326817264 99483 64.57.183.58 (17 Jan 2012 16:21:04 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Tue, 17 Jan 2012 16:21:04 +0000 (UTC) Keywords: OOP Posted-Date: 17 Jan 2012 11:21:04 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: x330-a1.tempe.blueboxinc.net comp.compilers:433 Torben Fgidius Mogensen schrieb: > The moderator opined: >> [Any program written in an OO language that allows inheritance or >> overloading uses function pointers, since that's how they're >> implemented. -John] > > If the inheritance and overloading can be resolved statically, function > pointers are not needed. But most OO languages use dynamic method > resolution by default, so what you say applies to nearly all OO > implementations. IMO the key is *virtual* methods, which require dynamic lookup in a Virtual Method Table or similar structure. In non-OO languages calling conventions like "call by name" also can require dynamic lookup of function addresses. Sorting and searching algorithms also typically are implemented with a compare function (pointer) argument. DoDi