Re: [RFC] Constant Scalar Expressions

From: Date: Wed, 14 Aug 2013 07:37:41 +0000
Subject: Re: [RFC] Constant Scalar Expressions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-68504@lists.php.net to get a copy of this message
On Wed, Aug 14, 2013 at 8:17 AM, Christian Stoller <stoller@leonex.de> wrote: >> 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. When a constant is based on a complex formula, it makes a lot of sense to keep it as it is defined or known. I had many projects (finance, stats and BI related areas) where I would have used constant expressions. As you suggested comments work fine, but do you know what my comments were? The expressions used to generate the constant, sounds double with little to no gain to me. Summary: huge +1 on that. -- Pierre @pierrejoye | http://www.libgd.org

« previous php.internals (#68504) next »