Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26535 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85982 invoked by uid 1010); 13 Nov 2006 11:30:28 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 85967 invoked from network); 13 Nov 2006 11:30:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Nov 2006 11:30:28 -0000 Received: from [127.0.0.1] ([127.0.0.1:10091]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 22/B6-40419-45758554 for ; Mon, 13 Nov 2006 06:30:28 -0500 X-Host-Fingerprint: 88.64.131.121 dslb-088-064-131-121.pools.arcor-ip.net Received: from [88.64.131.121] ([88.64.131.121:12725] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/05-40419-B0C48554 for ; Mon, 13 Nov 2006 05:42:20 -0500 Message-ID: To: internals@lists.php.net Date: Mon, 13 Nov 2006 11:42:17 +0100 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 88.64.131.121 Subject: Feature-Request - Macros From: phpinternals@thunder-2000.com (Mathias Bank) Hallo, you know, that there was often a discussion about a "ifsetor" function. I want to generalize this discussion. If you know LISP, there is a fantastic macro function which allows you to generate own syntax (not a c macro function, which is really bad). It would be fantastic, if php could implement such a macro function. One example (for ifsetor): you could define macro ifsetor($param1, $param2) { return "if (isset($param1)) return $param1; else return $param2; } use: $test = ifsetor($_GET["blubb"],null); All you have to do is to not execute the parameters given in the macro parameter list. Instead, you have to evaluate the return statement and then to execute this statement. In this way, all discussions about ifsetor (or anything like this) could be avoided. The macro function could even be extended to allow new blocks, but then we have to extend the syntax to allow reference to the body. In this way, I always extend the syntax of the parameter data: only variables would be matched. macro foreachkey($array as $key, :body $body) { return "foreach ($array as $key=>$__dev0) { $body }"; } know, you can call $secondArray = array(); foreachkey($myArray as $myKey) { $secondArray[] = $myKey; } this would be extended to foreach ($myArray as $myKey=>$__dev0) { $secondArray[] = $myKey; } and this code will be executed. As you see, with this macro functions, it could be achieved any individual syntax. It would be a pleasure, if php could support it. It could shorten a lot of code. Mathias