Re: [RFC] Constant Scalar Expressions (with constants)
| From: | Bob Weinand | Date: | Thu, 07 Nov 2013 16:02:21 +0000 |
| Subject: | Re: [RFC] Constant Scalar Expressions (with constants) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70062@lists.php.net to get a copy of this message | ||
Am 7.11.2013 um 14:34 schrieb Derick Rethans <derick@php.net>:
> On Thu, 7 Nov 2013, Bob Weinand wrote:
>> Hi!
>>
>> As you all know, Anthony Ferrara had withdrawn his RFC a few months ago, which was without
>> support for constants in these expressions:
>>
>> const foo = 10;
>> const bar = 10 * foo;
>>
>> The use of a constant in a declaration of a constant was not yet possible with his patch.
>>
>> That's what I changed.
>>
>> Enjoy reading the RFC at:
>>
>> https://wiki.php.net/rfc/const_scalar_exprs
>
>
> https://github.com/bwoebi/php-src/compare/const_scalar_exprs#diff-4d0b93094aafe8cf519b4f0a3322f471L590
>
> -#define IS_CALLABLE 10
> +#define IS_CONSTANT_AST 10
> +#define IS_CALLABLE 11
>
> Can I please suggest that you do not change existing constant values?
> You're using a macro to check for the constant type anyway, so you can
> do the complex checking for constant types in there.
Just comparing twice (> and <) should be faster than comparing three times (three times an
==).
Dmitry had suggested this to me. And I don't see the big disadvantage here as IS_CALLABLE is
anyway just used for the typehint. Nothing there which relies on the fact that IS_CALLABLE equals to
10.
> I'm also of the opinion that just " This can allow for writing far
> easier to understand code, by allowing for far more expressive code." is
> by far not enough of a justification for a syntax addition. Please
> please try to be convincing by having good arguments, presenting
> alternatives and cons.
Well, that's _the_ justification. I can also list other justifications, but that'd be just
other ways to express the same, so I just kept it simple.
Alternatives… don't really exist. (at least not in function signatures for example)
And cons? Can't think of any problem with it.
Bob
> cheers,
> Derick
>
> --
> http://derickrethans.nl |
> http://xdebug.org
> Like Xdebug? Consider a donation: http://xdebug.org/donate.php
> twitter: @derickr and @xdebug
> Posted with an email client that doesn't mangle email: alpine