In tune with the current 'const' patches by Sterling, and because I found
it useful (and more consistent than the original behaviour IMHO), attached
is a patch which implements compile-time constants in the global scope:
<?php
const something = 2, something_else = 4;
?>
The behaviour is the same as define(), only implemented in the compiler
instead of as a function.
Chris
In tune with the current 'const' patches by Sterling, and because I found
it useful (and more consistent than the original behaviour IMHO), attached
is a patch which implements compile-time constants in the global scope:<?php
const something = 2, something_else = 4;
?>
The behaviour is the same as
define(), only implemented in the compiler
instead of as a function.
You'll want to use static_scalar_expr when applied with my patch.
-Sterling
Chris
--
--
"Programming today is a race between software engineers stirring to
build bigger and better idiot-proof programs, and the universe trying
to produce bigger and better idiots. So far, the universe is winning."
- Unknown
I've been thinking about this for awhile, and seeing these patches about
'const' at compile-time I thought I would throw this in here now...
Instead of patching the engine for these constant values, wouldn't these
things be better served in a module? I've already worked on a basic
module that hooks into zend_compile() and does pre-processing before
giving the script over to PHP... Hence you'd have something identical to
C's preprocessing.
<?php
#define MYVAR 1;
Echo MYVAR;
?>
If there is interest, I'd like to be able to include this module in PHP5
once its been cleaned up...
John
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
John Coggeshall
john at coggeshall dot org http://www.coggeshall.org/
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
-----Original Message-----
From: Chris Vandomelen [mailto:chrisv@revhosting.com]
Sent: Tuesday, April 08, 2003 3:45 PM
To: internals@lists.php.net
Subject: [PHP-DEV] [PATCH] 'const' in global scopeIn tune with the current 'const' patches by Sterling, and
because I found it useful (and more consistent than the
original behaviour IMHO), attached is a patch which implements
compile-time constants in the global scope:<?php
const something = 2, something_else = 4;
?>
The behaviour is the same as
define(), only implemented in the
compiler instead of as a function.Chris