Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8808 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89746 invoked by uid 1010); 28 Mar 2004 17:10:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89722 invoked from network); 28 Mar 2004 17:10:31 -0000 Received: from unknown (HELO shiva.mind.de) (212.42.230.204) by pb1.pair.com with SMTP; 28 Mar 2004 17:10:31 -0000 Received: from [192.168.1.105] (p508EB561.dip.t-dialin.net [80.142.181.97]) by shiva.mind.de (Postfix) with ESMTP id C747397B4F; Sun, 28 Mar 2004 19:10:39 +0200 (CEST) Date: Sun, 28 Mar 2004 19:10:50 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <193608357171.20040328191050@marcus-boerger.de> To: Luna Kid Cc: internals@lists.php.net In-Reply-To: <20040328165557.65979.qmail@pb1.pair.com> 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> <20040328165557.65979.qmail@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: class constants in RC1 - why not __self:: then? From: helly@php.net (Marcus Boerger) Hello Luna, Sunday, March 28, 2004, 6:56:00 PM, you wrote: > "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. No need for that we have 'self': php -r 'class c { const c="Hello\n"; static function f() { return self::c; }} echo c::f();' -- Best regards, Marcus mailto:helly@php.net