Am 13.08.2013 um 14:13 schrieb "Anthony Ferrara" <ircmax...@gmail.com>:

> Hello all,
> 
> I'd like to propose a new RFC for 5.NEXT:
> 
> https://wiki.php.net/rfc/const_scalar_expressions
> 
> This allows for defining constant expressions which are resolved at compile
> time.
> 
> for example:
> 
> const FOO = 1 + 1;
> static $bar = 1 << 2;
> function foo($a = 1 | 2) {}
> class foo {
>    public $bar = 1 << 2;
> }
> 
> Thoughts?
> 
> Anthony

It really would be nice to use constants in these constant expressions.

I think this would be particulary useful when using bitwise operators. Example:

const FLAG_A = 1;
const FLAG_B = 2;
const FLAG_C = 4;

With this proposal we would write:
function func ($arg = 1 | 2 | 4) # we now need to lookup first which constants 
have values 1, 2 and 4

But it would be much more understandable if we were able to write:
function func ($arg = FLAG_A | FLAG_B | FLAG_C)

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

Reply via email to