Req #69738 [Opn]: Declare immutable variables

From: Date: Tue, 02 Jun 2015 15:01:31 +0000
Subject: Req #69738 [Opn]: Declare immutable variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193074@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69738&edit=1 ID: 69738 Updated by: rasmus@php.net Reported by: ugoren at interwise dot co dot il Summary: Declare immutable variables Status: Open Type: Feature/Change Request Package: Variables related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Like which character? When you look through the parser you will find that there are very few single-character operators available. @ is the error-suppression character. Previous Comments: ------------------------------------------------------------------------ [2015-06-02 14:45:04] ugoren at interwise dot co dot il You know, the # sign could be replaced with @ or any other character ------------------------------------------------------------------------ [2015-06-02 14:42:00] rasmus@php.net And break millions of lines of code out there that use # comments? No chance. ------------------------------------------------------------------------ [2015-06-02 06:51:50] ugoren at interwise dot co dot il I was able to implement this feature myself: http://stackoverflow.com/questions/30570763/replace-the-in-php-variable-declaration/30588938#30588938 I would love to see this feature implemented (and extended) in PHP7 ------------------------------------------------------------------------ [2015-06-01 12:45:58] cmb@php.net At first it should be noted that this syntax (# instead of $) is not possible, because # starts a line comment (it's an alternative to //). | #a=array(1,2); | #a=array(1,3);//ok | #a[1]=4;//error: modifying immutable variable If the second statement is allowed, I wouldn't say that the variable is immutable, but rather that the value is immutable. It is, however, already possible to have immutable values by using immutable objects. ------------------------------------------------------------------------ [2015-06-01 11:13:54] chx@php.net The language specification describes the language as it is. This is a feature request against the language itself. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=69738 -- Edit this bug report at https://bugs.php.net/bug.php?id=69738&edit=1

« previous php.bugs (#193074) next »