FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Why is polymorphism in PHP not like other languages? Is there a bug in PHP?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Why is polymorphism in PHP not like other languages? Is there a bug in PHP? [message #185045 is a reply to message #185027] Tue, 25 February 2014 02:43 Go to previous messageGo to previous message
Robert Heller is currently offline  Robert Heller
Messages: 60
Registered: December 2010
Karma:
Member
Note a compiled language (like C++ or Java) need up-front knowledge about
things, while *intrepreted* languages defer resolving things until runtime.
Partitularly with languages where classes can be defined 'on the fly'.

At Mon, 24 Feb 2014 13:16:06 -0800 (PST) "kurtk(at)pobox(dot)com" <kurtk(at)pobox(dot)com> wrote:

>
> Evidently, PHP just works differently. Even though Quackologist::update(\Sp=
> lSubject) takes a reference to \SplSubject, this fine provide you pass (at =
> runtime) a class derived from SplSubject that implements whoami(). Only if =
> were to pass an SplSubject instance that does not implement whoami() will y=
> ou get an runtime error.=20
>
> C++, on the other hand, would complain
>
> error: no member named 'whoami' in 'Base'
>
> because Base has no whoami() method.
>

--
Robert Heller -- 978-544-6933 / heller(at)deepsoft(dot)com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Completely stumped
Next Topic: Correlating curl resources to some other object.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 21:51:32 GMT 2024

Total time taken to generate the page: 0.03921 seconds