|
Posted by Jerry Stuckle on 09/30/74 11:44
Kimmo Laine wrote:
> "Emil" <emjot_wytnij_to_@podczta.onet.pl> wrote in message
> news:e15ag1$3ee$1@news.onet.pl...
>
>>Is there any hope that new versions of PHP
>>will support macros similar to C or C++?
>>I've searched manual and didn't find anything
>>except define directive, but it can be used
>>to define constant values only.
>>Of course it is not THAT neccessary functionality,
>>but it could be very useful.
>>
>
>
>
> What's the actual difference between a function and a macro? How would use
> of macros differ from functions?
>
> Let's pretend there is a way of defining a macro in php...
> define ("MAX($a,$b)", "(($a<$b)?$b:$a)");
>
> vs.
>
> function max( $a, $b ) {
> return $a < $b ? $b : $a;
> }
>
> And use them like this:
> MAX($a,$b); // This is macro, so much easier!
> max($a,$b); // This is plain old dull function! Bah, no no, not like
> this...
>
> I mean.... WTF?
>
Macros are more efficient.
Personally, one construct I use heavily and would like to replace with a macro:
$var = isset($_POST['postvar']) ? $_POST['postvar'] . 'default value';
I use something similar for a get/post, session and cookie values. It would be
very nice to have a macro.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|