On Wed, May 19, 2010 at 7:04 PM, Richard Quadling
<rquadl...@googlemail.com> wrote:
> On 19 May 2010 11:21, Tjerk Anne Meesters <datib...@php.net> wrote:
>> On Wed, May 19, 2010 at 5:52 PM, Frederic Hardy
>> <frederic.ha...@mageekbox.net> wrote:
>>> Hello !
>>>>
>>>> AFAIK class constants are optimized for speed and therefore don't
>>>> support expressions; don't expect this to change any time soon ;-)
>>>>
>>>>> Is there any feature request about constant and expression ?
>>>>> I would like to write something like that :
>>>>>
>>>>> <?php
>>>>>
>>>>> namespace foo\bar\directories {
>>>>>    const tmp = __DIR__ . '/tmp';
>>>>> }
>>>>>
>>>>> ?>
>>>
>>> So the best solution is something like <?php
>>> define('foo\bar\directories\tmp', __DIR__ . '/tmp'); ?>...
>>> It 's strange that "define()" function can do something that the "const"
>>>  keyword can't do, even if "const" keyword evaluation is done at compilation
>>> time and "define()" evaluation is done at runtime.
>>
>> That's why there's a cost penalty to using define().
>>
>> I wrote a small article that gives an idea of the speed differences:
>> http://shwup.blogspot.com/2010/04/about-constants.html
>>
>>
>>>
>>> Best regards,
>>> Fred.
>>>
>>> --
>>> ========================================================================
>>> Frédéric Hardy : Architecte d'application/Admin. système/Ergonome
>>>        Status : En recherche d'emploi
>>> ========================================================================
>>>
>>>
>>
>>
>>
>> --
>> --
>> Tjerk
>
> With regard to HiDef and the hidef.ini_path setting, and the comment
> on [1] regarding "However, all this goodness comes with a drawback:
> configuration settings are instance wide, which impacts all setups of
> PHP that runs beyond a single web request (e.g. Apache module or
> FastCGI).", could the ini entry be placed in a ...
>
> [HOST=]
>
> section in the ini file? [2]
>
> If so, could this be the best solution?

The speed of hidef is accomplished by having only MINIT and MSHUTDOWN
handlers; it would be interesting to see how speed is affected by
moving some logic to the request init/shutdown; it should still have
the benefit of constants being defined at compile time.

>
> Regards,
>
> Richard.
>
> [1] http://shwup.blogspot.com/2010/04/about-constants.html
> [2] http://docs.php.net/manual/en/ini.sections.php
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to