Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14571 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47533 invoked by uid 1010); 3 Feb 2005 16:40:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47518 invoked from network); 3 Feb 2005 16:40:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2005 16:40:39 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.4/2.6 Received: from ([80.74.107.235:51778] helo=mail.zend.com) by pb1.pair.com (ecelerity HEAD (r4105:4106)) with SMTP id FD/B9-29932-50452024 for ; Thu, 03 Feb 2005 11:40:38 -0500 Received: (qmail 11927 invoked from network); 3 Feb 2005 16:40:35 -0000 Received: from shire.zend.office (10.1.2.160) by internal.zend.office with SMTP; 3 Feb 2005 16:40:35 -0000 Date: Thu, 3 Feb 2005 18:40:35 +0200 (IST) X-X-Sender: frodo@shire.zend.office To: =?iso-8859-1?Q?Terje_Sletteb=F8?= cc: internals@lists.php.net In-Reply-To: <02d901c50a0c$b2c0c3f0$a900000a@adstate.local> Message-ID: References: <5.1.0.14.2.20050201111730.0299da70@localhost> <42020015.5090209@cschneid.com> <02d901c50a0c$b2c0c3f0$a900000a@adstate.local> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] PHP 5.1 - operator overloading From: stas@zend.com (Stanislav Malyshev) TS>>If $a is an object of a class, then they would both be in the class TS>>definition. One is called "add", and the other is called "operator+". What's TS>>the problem with that? The problem is that you can't really know what $a is - PHP is typeless. You'll have to trace all the program up to $a's assignment and hope you didn't miss reassignment on the way. TS>>It would if operator overloading was allowed on free functions (as it is in TS>>C++). E..g: You can't do it like in C++, because in C++ function signature includes argument types, and in PHP it does not. I.e., you can't write two operators - one for complex+int and one for complex+complex. In general, it's too much trouble for too little gain - except for select things like complex and matrices (and maybe two more things like this) I don't see any value in having, say, + overloaded. Using good old methods will never fail you. -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115