List Info

Thread: note 78533 added to language.oop5.typehinting




note 78533 added to language.oop5.typehinting
user name
2007-10-16 11:20:51
To Nikivich and Edorian:

There are many times when you would use an equals() method
other than to find out if the two objects are the same
object. Think of all the primitive wrapper classes in Java,
for example -- if you create two new Integer()'s with
identical values, equals() returns true, even though they
are two different objects. There would be no reason to allow
someone to perform an equals() between an Integer and, say,
a GregorianCalendar -- it just doesn't make sense. In Java
you would attempt this and probably get a
ClassCastException, but in PHP no such facility exists, so
the best way to prevent this would be through type hinting.

The point Nicholas was making is that you can't specify a
stricter type hint on an inherited method, and despite your
arguments, that would be a truly useful thing to be able to
do.

(True overloading would be a better way, IMHO, but *shrug*)
----
Server IP: 209.41.74.194
Probable Submitter: 163.191.24.14
----
Manual Page -- http://www.php.net/manual/en/language.oop5.typehinting
.php
Edit        -- https://master
.php.net/note/edit/78533
Del: integrated  -- h
ttps://master.php.net/note/delete/78533/integrated
Del: useless     -- http
s://master.php.net/note/delete/78533/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/78533/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/78533/spam
Del: non-english -- 
https://master.php.net/note/delete/78533/non-english
Del: in docs     -- http
s://master.php.net/note/delete/78533/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78533
Reject      -- https://mast
er.php.net/note/reject/78533
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )