Re: [RFC] Constant Scalar Expressions (with constants)
| From: | Sebastian Krebs | Date: | Thu, 07 Nov 2013 12:43:15 +0000 |
| Subject: | Re: [RFC] Constant Scalar Expressions (with constants) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70051@lists.php.net to get a copy of this message | ||
2013/11/7 Lars Strojny <lars@strojny.net>
> Hi Bob,
>
> thanks for your work, it’s awesome. One thing about constants:
>
> Take this example:
>
> const FOO = 2;
>
> class Klass
> {
> const FOO = 1;
> const BAR = FOO;
> }
>
> Here FOO is ambiguous, as it could resolve to 2 or to 1. If I understood
> it correctly, global constants are not yet implemented but I would suggest
> to always force prefixing the constant to get rid of the ambiguity and
> allow for future extension.
>
> const FOO = 2;
>
> class Klass
> {
> const FOO = 1;
> const BAR = self::FOO;
> }
>
> Does that make sense?
>
Yes, also from the consistency point of view: I'd expected to refer class
constants via its class name (or self/static). Having to ways to refer them
is confusing.
>
> cu,
> Lars
>
> On 07 Nov 2013, at 13:01, Bob Weinand <bobwei9@hotmail.com> 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
> >
> > Bob Weinand
> >
> > Special thanks go to Dmitry who had helped me a lot with feedback and a
> deep review of the patch.
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
--
github.com/KingCrunch