Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26575 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19350 invoked by uid 1010); 14 Nov 2006 19:54:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 19335 invoked from network); 14 Nov 2006 19:54:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Nov 2006 19:54:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=boards@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=boards@gmail.com; sender-id=pass; domainkeys=good Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.82.230 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: boards@gmail.com X-Host-Fingerprint: 66.249.82.230 wx-out-0506.google.com Linux 2.4/2.6 Received: from [66.249.82.230] ([66.249.82.230:24720] helo=wx-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/E2-33594-DDE1A554 for ; Tue, 14 Nov 2006 14:54:06 -0500 Received: by wx-out-0506.google.com with SMTP id i27so1846940wxd for ; Tue, 14 Nov 2006 11:54:03 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:organization:to:subject:date:user-agent:references:in-reply-to:mime-version:content-type:content-transfer-encoding:message-id; b=sEk8T75RuBBiPBgdxvNXO9TfvkUOfcKoRfH6cZM3BoduoGsL5ZzHx122AsBvtGpNnM2WVDsVoFg1Hsvd6ueaE5IAeDorVUs78ntg4Aji5RStlnfUAJ8LfetPUyB2TE4D/gh6mwU7OKculi6tsqkMmhfnh6/RBzTM0cqbdEnTdq0= Received: by 10.90.63.16 with SMTP id l16mr1536968aga.1163534042235; Tue, 14 Nov 2006 11:54:02 -0800 (PST) Received: from jesusbox ( [67.184.88.155]) by mx.google.com with ESMTP id g3sm11095274wra.2006.11.14.11.54.00; Tue, 14 Nov 2006 11:54:00 -0800 (PST) Organization: LX To: internals@lists.php.net Date: Tue, 14 Nov 2006 13:53:59 -0600 User-Agent: KMail/1.9.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart4063570.zGkOj8FtHD"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-ID: <200611141353.59923.boards@gmail.com> Subject: Re: [PHP-DEV] Feature-Request - Macros From: boards@gmail.com (Matt Sicker) --nextPart4063570.zGkOj8FtHD Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Monday 13 November 2006 04:42, Mathias Bank wrote: > 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 =3D 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=3D>$__dev0) { > $body > }"; > } > > know, you can call > $secondArray =3D array(); > foreachkey($myArray as $myKey) { > $secondArray[] =3D $myKey; > } > > this would be extended to > foreach ($myArray as $myKey=3D>$__dev0) { > $secondArray[] =3D $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 This could also help with writing code compatible across different major=20 PHP versions (4, 5, and 6). It could help fuel upgrades so that=20 supporting PHP4 isn't such a hassle in the future. I love the idea (especially the Lisp implementation). =2D-=20 Matt Sicker --nextPart4063570.zGkOj8FtHD Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBFWh7X5tcAKF5t41MRAo0SAJ9UJc6y+yOAp7vXU7QGn601J+V5pwCePZHq zwLVlmO6P3jMbjSNry4wgKk= =GZMz -----END PGP SIGNATURE----- --nextPart4063570.zGkOj8FtHD--