Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8807 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66004 invoked by uid 1010); 28 Mar 2004 16:55:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 65980 invoked by uid 1007); 28 Mar 2004 16:55:57 -0000 Message-ID: <20040328165557.65979.qmail@pb1.pair.com> To: internals@lists.php.net References: <5.1.0.14.2.20040315080605.01732e80@127.0.0.1> <5.1.0.14.2.20040315080605.01732e80@127.0.0.1> <5.1.0.14.2.20040315174015.0a198dd0@127.0.0.1> Date: Sun, 28 Mar 2004 18:56:00 +0200 Lines: 50 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Posted-By: 81.0.84.246 Subject: Re: class constants in RC1 - why not __self:: then? From: lunakid@neuropolis.org ("Luna Kid") "Andi Gutmans" wrote in message news:5.1.0.14.2.20040315174015.0a198dd0@127.0.0.1... > At 10:07 AM 3/15/2004 -0500, Hans Lellelid wrote: > > ... > >You must now use self::MY_CONST to reference the class constant. While I > >can see that the pre-RC1 behavior would not provide a way to access global > >constant if class had const of same name ... I figured I'd ask anyway > >whether this change is intended or a side-effect of some other fix. I > >fall into the category of people who were really enjoying not having to > >specify self:: before (so now I have a lot of code to fix, apparently). > ... > I fixed it intentionally. That piece of code was left over from the days of > our broken namespaces implementation where we would do two lookups. Methods > were fixed a long time ago but we forgot to remove the old code from constants. > > Andi Well, I guess there is no easy solution, but anyhow, this is still very unfortunate. The basic "Don't Repeat Yourself" (or "DRY") principle, which could forunately eliminate the function Classname() { // constructor syntax replacing it with the much cleaner and saner __construct (THANKS!!!), now fails to prevent creeping in of another sort of harmful hardcoded redundancy to our code... I'd say I'd rather pay the price of any double lookup any day than loading my code with useless duplication of information. As a cheap and effective compromise, would that be a possible to introduce something like a __thisclass keyword so that those of us who are concerned about code duplication could avoid this newly introduced unnecessary repeating of class names when qualifying consts within the defining class? This way (writing __thisclass::MYCONST instead of MyParticularClassName::CONST we could freely decide to favor clean style, or performance, depending on the specific situation. Whichever way, thanks very much for your efforts, guys! The Luna Kid