Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29815 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73779 invoked by uid 1010); 26 May 2007 18:43:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 73763 invoked from network); 26 May 2007 18:43:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2007 18:43:53 -0000 Authentication-Results: pb1.pair.com header.from=info@adaniels.nl; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=info@adaniels.nl; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain adaniels.nl from 82.94.236.173 cause and error) X-PHP-List-Original-Sender: info@adaniels.nl X-Host-Fingerprint: 82.94.236.173 loco.helderhosting.nl Linux 2.5 (sometimes 2.4) (4) Received: from [82.94.236.173] ([82.94.236.173:34219] helo=loco.helderhosting.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/B2-49291-6EF78564 for ; Sat, 26 May 2007 14:43:51 -0400 Received: from [192.168.1.170] (a80-126-54-132.adsl.xs4all.nl [80.126.54.132]) by loco (Postfix) with ESMTP id 9F20E1150246; Sat, 26 May 2007 20:43:46 +0200 (CEST) Message-ID: <46587FE0.6030100@adaniels.nl> Date: Sat, 26 May 2007 20:43:44 +0200 User-Agent: Thunderbird 1.5.0.10 (X11/20070403) MIME-Version: 1.0 To: Gregory Beaver , internals@lists.php.net References: <2C.70.31507.8DE18564@pb1.pair.com> <465820AB.7030102@gmail.com> <465829C0.8060008@mediawave.nl> <465837F7.1000401@adaniels.nl> <465845F9.8010209@chiaraquartet.net> In-Reply-To: <465845F9.8010209@chiaraquartet.net> Content-Type: multipart/alternative; boundary="------------030803060203070004090306" Subject: Re: [PHP-DEV] $var::$static From: info@adaniels.nl (Arnold Daniels) --------------030803060203070004090306 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi again, I'm aware that you can do `$a = $group . '_' . $fn; $a();`, but you can do `$b = $group . '_' . $var; echo $$b;` as well as `echo ${$group . '_' . $var}`. It's a mater of style, not if there is any way to get it done. Yes I've read about 'static::' some time ago, but forgot about it. Thanks for pointing it out. I (unfortunately) took that as an example, but it wasn't the case I wanted to make. To my opinion, the ease with which you can use output of an expression to be used as name of a variable is wonderful. The code is so much clearer than when you have to create all kind of temporary variables and/or use eval. I think it is unfortunate that the same logic isn't available for functions and classes. Best regards, Arnold Gregory Beaver wrote: > Arnold Daniels wrote: > >> Hi, >> >> I agree that $this::$var isn't really logical, since $this is an object >> and not a class name. But I do not see why $class::$var shouldn't work, >> or $class::$method() for that method. You can also do $function(). >> >> Also I want to suggest that brackets can be used more freely. Currently >> you can use ${$group . '_myvar'}, but you can't do the same for >> functions and classes. It would be great if you could use {$group . '_' >> . $fn}() and {get_class($this)}::$var. >> >> The way to solve this problems right now is to use eval('return ' . >> get_class($this) . '::$var;') for getting the value. Getting a reference >> to the variable to set it, is even more messy. You need to do something >> like eval('$cvar =& ' . get_class($this) . '::$var;'); $cvar = 'bye';. >> >> Anyway, it is not so nice, but doable in user space fairly easily. So I >> don't see why anything needs to be added in PHP 5. It would be nice to >> have a better method in PHP 6 though. >> >> From Holland with love, >> Arnold >> > > Hi Arnold, > > $a = $group . '_' . $fn; > $a(); > ?> > > As for get_class($this)::$var it pays to search the mailing list > archives. the static:: keyword is being using in PHP 6 to do exactly > what you want from within a class. Outside of a class, $var::$value > doesn't work yet, but the implementation of static may make it possible > to implement $var::$value as well. > > Greg > > P.S. The list archives are http://marc.info/?l=php-dev and are searchable > > --------------030803060203070004090306--