RE: [PHP-DEV] [RFC] Constant Scalar Expressions
| From: | Sebastian Krebs | Date: | Wed, 14 Aug 2013 06:23:02 +0000 |
| Subject: | RE: [PHP-DEV] [RFC] Constant Scalar Expressions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68502@lists.php.net to get a copy of this message | ||
Am 14.08.2013 08:17 schrieb "Christian Stoller" <stoller@leonex.de>:
>
> > 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.
>
> What should that be for?
>
> > const FOO = 1 + 1;
> > const BAZ = "HELLO " . "WORLD!";
>
> Why not just writing
>
> const FOO = 2;
> const BAZ = "HELLO WORLD!";
>
> I think it makes code les readable. And if you want to give an important
hint for the reader of the code, you can still write comments.
Other examples are better I think
const $flag3 = 1<<7;
const $timeout = 60*8;
For strings it can make sense to avoid newlines, when you want to split a
long string onto several lines.
>
>
> Best regards
> Christian