#46017 [Opn->WFx]: Make C-Like Macros for PHP
| From: | pajoye@php.net | Date: | Sun, 27 Dec 2009 13:17:54 +0000 |
| Subject: | #46017 [Opn->WFx]: Make C-Like Macros for PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146135@lists.php.net to get a copy of this message | ||
ID: 46017
Updated by: pajoye@php.net
Reported By: ben at umingo dot de
-Status: Open
+Status: Wont fix
Bug Type: Feature/Change Request
Operating System: Windows
PHP Version: 5.2.6
New Comment:
See the previous reports for the (good) reasons not to implement
macros.
Previous Comments:
------------------------------------------------------------------------
[2009-12-27 08:01:17] john2496 at gmail dot com
I agree, php needs macros. There is no way to represent a set of
function calls that need to be made within the local scope.
I'd need to use the following line of code every time I wanted to merge
variables to the local scope.
extract(array_merge_recursive(get_defined_vars(), $anArray)));
instead of..
extract_recursive($anArray);
------------------------------------------------------------------------
[2008-09-07 13:50:01] ben at umingo dot de
Description:
------------
Hello people, i want to ask you for macros for PHP.
Main purpose is to switch projects between testing, developing and
production state without performance penalties.
All these runtime if's could be skipped and that is jsut one example.
It just gives you some more options
I really miss macros from C and C++ days ...
another useful example is for logging,
I dont want to write a __LINE__ and __FILE__ everytime i log something.
It would be much nicer to use a macro that will expand my logfunction
with these parameters before compiling ... you know what i mean
The bigger the project the bigger the effect of compiling times and
execution times ... This could really be a speedup and at all nobody is
forced to use macros.
(in case php scripts are cached and precompiled)
Reproduce code:
---------------
//projectstate
//0 testing
//1 developing
//2 production
#define projectstate = 0
//some code ...
#if projectstate == 0
//write some log, some output or whatever
}
#endif
//some other code
Expected result:
----------------
With macros, the code would be just
//some code ...
//some other code...
Actual result:
--------------
Without macros, the code would be
//some code
//an if-querry for projectstate
//some hundred lines of code to parse and evaluate
//endif
//some other code
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46017&edit=1