Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20174 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40238 invoked by uid 1010); 18 Nov 2005 21:00:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 40223 invoked from network); 18 Nov 2005 21:00:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2005 21:00:15 -0000 X-Host-Fingerprint: 206.81.46.34 unknown Received: from ([206.81.46.34:29236] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 16/48-07637-FD04E734 for ; Fri, 18 Nov 2005 16:00:15 -0500 Message-ID: <16.48.07637.FD04E734@pb1.pair.com> To: internals@lists.php.net Date: Fri, 18 Nov 2005 16:00:27 -0500 User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 References: <05311866.20051115205152@ionzoft.com> In-Reply-To: <05311866.20051115205152@ionzoft.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 206.81.46.34 Subject: Re: PHP Macros From: gamblergluck@yahoo.com (Roman Ivanov) Jason Garber wrote: > Hello Internals, > > Remember the ifsetor() discussion? There were many, many people for > it, and many people that did not see the point. To this day, it's > not been allowed into the source tree, and I don't see any way to > change that. So... > > Please consider (some form of) this if it's possible: > > > define_macro square(x) > { > ((x) * (x)) > } > > define_macro ifsetor(x, y) > { > (isset(x) ? x : y) > } > > $n = square($n); > > > If the parser/compiler sees one of these, then it will add it to > it's list of "macros", and when it runs into the usage of one, it > will do a little token-replacing before compiling it... > > Is it technically doable? I dare to suggest PHP replacement: define('SQUARE_X', 'return $x * $x;'); $x = 10; echo eval(SQUARE_X);