Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:30074 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91727 invoked by uid 1010); 5 Jun 2007 17:17:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 91711 invoked from network); 5 Jun 2007 17:17:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2007 17:17:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=colder@php.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=colder@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 213.239.212.54 cause and error) X-PHP-List-Original-Sender: colder@php.net X-Host-Fingerprint: 213.239.212.54 dns1.omne-serveurs.net Linux 2.4/2.6 Received: from [213.239.212.54] ([213.239.212.54:52591] helo=dns1.omne-serveurs.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/64-56966-3AA95664 for ; Tue, 05 Jun 2007 13:17:25 -0400 Received: (qmail 18750 invoked from network); 5 Jun 2007 17:17:18 -0000 Received: from 80.218.249.160 by dns1 (envelope-from , uid 1004) with qmail-scanner-1.23 (clamdscan: 0.82. spamassassin: 3.0.1. perlscan: 1.32. Clear:RC:1(80.218.249.160):. Processed in 0.034382 secs); 05 Jun 2007 17:17:18 -0000 Received: from 80-218-249-160.dclient.hispeed.ch (HELO ?10.0.0.1?) (80.218.249.160) by dns1.omne-serveurs.net with (DHE-RSA-AES256-SHA encrypted) SMTP; 5 Jun 2007 17:17:18 -0000 Message-ID: <46659A9E.1020202@php.net> Date: Tue, 05 Jun 2007 19:17:18 +0200 User-Agent: Thunderbird 1.5.0.7 (X11/20060909) MIME-Version: 1.0 To: Bart de Boer CC: Jochem Maas , internals@lists.php.net, Ken Stanley References: <56275.216.230.84.67.1180484964.squirrel@www.l-i-e.com> <465D9040.6030001@iamjochem.com> <43689.216.230.84.67.1180643866.squirrel@www.l-i-e.com> <465FC76B.6030208@mediawave.nl> <4660A44F.6060802@mediawave.nl> <46657E94.1030900@iamjochem.com> <2689.192.87.117.168.1181060919.squirrel@www.mediawave.nl> In-Reply-To: <2689.192.87.117.168.1181060919.squirrel@www.mediawave.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] late static binding (please break BC?) From: colder@php.net (Etienne Kneuss) Bart de Boer wrote: > I thought late static binding had something to do with accessing static > _variables_ in child classes. You're currently solving that problem by > defining a static function getTableName() in the child class. But I think > that isn't very efficient when you're dealing with complex objects and/or > arrays which would need to be accessed frequently. > > If it were possible your code example could be solved as: > > > class Data { > static function findRange() { > if (!child::$tableName) > throw new Exception('WTF'); > else > return child::$tableName; > } > } > > class Prod { > static $tableName = 'PRODS'; > } > > ?> > > But it seems this feature request belongs in a different thread. :) > > > Late static binding can also be used to access static properties, of course. The same class resolution mechanism is used by foo::$member and foo::method(); so the keyword would apply to both. Same with magic syntax like $a = new self(); > > Now I understand why this:: might be confusing since it is meant for > objects. self:: would mean we can't access stuff in the current class > anymore. What about > > derived:: > > or > > extended:: > > ? > It's always dangerous to introduce a new keyword, as it can/will break BC (i.e what if somebody has defined a function derived(), the parser would choke on that). I'm personally fine with static, even if it may eventually introduce some confusion. Regards -- Etienne Kneuss http://www.colder.ch Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal