Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14600 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80440 invoked by uid 1010); 3 Feb 2005 22:21:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 80283 invoked from network); 3 Feb 2005 22:21:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2005 22:21:18 -0000 X-Host-Fingerprint: 217.13.4.94 bgo1smout1.broadpark.no Solaris 9 Received: from ([217.13.4.94:49400] helo=bgo1smout1.broadpark.no) by pb1.pair.com (ecelerity HEAD (r4105:4106)) with SMTP id 85/3A-10528-FC3A2024 for ; Thu, 03 Feb 2005 17:21:03 -0500 Received: from bgo1sminn1.broadpark.no ([217.13.4.93]) by bgo1smout1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IBC0037WWHZA460@bgo1smout1.broadpark.no> for internals@lists.php.net; Thu, 03 Feb 2005 23:15:35 +0100 (CET) Received: from pc ([80.203.129.71]) by bgo1sminn1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with SMTP id <0IBC00F82WUV9R70@bgo1sminn1.broadpark.no> for internals@lists.php.net; Thu, 03 Feb 2005 23:23:19 +0100 (CET) Date: Thu, 03 Feb 2005 23:23:17 +0100 To: internals@lists.php.net Message-ID: <04be01c50a3e$f5afb3b0$0300000a@pc> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Mailer: Microsoft Outlook Express 6.00.2800.1437 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT X-Priority: 3 X-MSMail-priority: Normal References: <5.1.0.14.2.20050201111730.0299da70@localhost> <030301c50a15$024897b0$a900000a@adstate.local> <42027836.2050403@prohost.org> Subject: Re: [PHP-DEV] PHP 5.1 From: tslettebo@broadpark.no (=?iso-8859-1?Q?Terje_Sletteb=F8?=) > From: "Jani Taskinen" > > C++ is not PHP and the sooner you realize this the better it will be. I do realise it. However, I don't accept that as an argument against things like operator overloading, which is found in scripting languages comparable to PHP. > Adding operator overloading will add yet another layer of "magic" that > will confuse users, who for the most part have demonstrated that they > are not ready for such features. Judging from much of the PHP code I've seen, I'm sorry to say that you may be right... However, that doesn't mean _no_ users are ready for it. > If anything it'll only over complicate > applications making them neigh impossible to debug and require all sorts > of hackery inside the language itself to support this functionality. My experience isn't that misuse of language features is the biggest cause of messy code, as inexperienced developers typically aren't aware of more "advanced" features, and therefore don't use them. Rather, my experience is that the biggest cause of messy code is simply lack of competence, beyond knowing the language itself. Learning to be a good programmer takes many years, regardless of language. Those who are experienced enough to "shoot themselves in the foot", but not experienced enough to aim properly, :) might, however, obfuscate code with "misuse" of more "advanced" language constructs (variable variables and variable functions comes to mind), but that doesn't mean we should forbid these features in the language! Used properly, if anything, the features proposed in my postings (like overloading, and optional type checking) would allow people to _simplify_ their code. C++ code is typically simpler than Java code, for this reason. Take this example (incrementing an element in a map): C++: ++my_map[key]; Java: if ( !my_map.containsKey( key ) ) my_map.put( key, new Integer( 1 ) ); else { Integer count = ( Integer )my_map.get( key ) ); int icount = count.IntValue(); my_map.put( key, new Integer( ++icount ) ); } Operator overloading isn't the only thing playing a part, here (the ability to treat built-in and user-defined types the same way is another major factor), but it's a major factor. Now, for this particular example, PHP actually has a similarly succinct form, but that's only because the PHP array _is_ a map, so you have a built-in type with operators: ++$my_map[$key]; The advantage of operator overloading is similar to the advantage of symbolic notation in mathematics: It allows you to succinctly express your intent, and it's also international. Regards, Terje