ID:               46017
 Comment by:       john2496 at gmail dot com
 Reported By:      ben at umingo dot de
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: Windows
 PHP Version:      5.2.6
 New Comment:

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);


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to