[PHP-BUG] Req #69738 [NEW]: Declare immutable variables
[email protected] ("ugoren at interwise dot co dot il")
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
From: ugoren at interwise dot co dot il
Operating system:
PHP version: Irrelevant
Package: PHP Language Specification
Bug Type: Feature/Change Request
Bug description:Declare immutable variables
Description:
------------
I would like to have an option to declare immutable variables,
for example
$a=1;// is a mutable variable
#b=1;// is an immutable variable
The advantages of immutable variables are numerous:
1. caching function return values
2. parallelism (no shared memory)
3. pass variables by reference
4. Testability, just record a pure function's input and outputs, and you
have automatically generated unit-tests.
Test script:
---------------
//sample code:
#a=array(1,2);
#a=array(1,3);//ok
#a[1]=4;//error: modifying immutable variable
//pure functions:
function #pure_function(#a,#b)
{
return #a+#b;
}
--
Edit bug report at https://bugs.php.net/bug.php?id=69738&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69738&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69738&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69738&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69738&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69738&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69738&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69738&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69738&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69738&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69738&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69738&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69738&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69738&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69738&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69738&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69738&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69738&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69738&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69738&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69738&r=mysqlcfg