Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39191 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45090 invoked from network); 22 Jul 2008 14:37:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jul 2008 14:37:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 72.14.220.153 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 72.14.220.153 fg-out-1718.google.com Received: from [72.14.220.153] ([72.14.220.153:44675] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/53-46193-FB0F5884 for ; Tue, 22 Jul 2008 10:37:52 -0400 Received: by fg-out-1718.google.com with SMTP id 16so1182824fgg.23 for ; Tue, 22 Jul 2008 07:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :to:subject:cc:mime-version:content-type; bh=Va63Nfoh6sfiFFCiORj5Xs+nvdzV1O2J+QJCol11o3Q=; b=JedvDBIwC+46LWWWokLcTmaZ9mOboRQOg2u9FuBew2PufOnhnbwcJ2x1fPY1AZjQc8 Hkxrxn0VFMccC4wUdq+bEwnzYS3MuyPHaseogrQZOuVPhFJsh+JrTXOrCnofHay/bW/L jll/2EyguxHotbZIIHcviyWARpGayvIgWfH1w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:mime-version :content-type; b=PE+UKrP8OLfyvdYBXi8EfSz96hosbs6P1gRQ+f1WgvRcjwFmDdR3ZfCotVF7shz1Nc ziTKsNxGikV2EwhpIrSWCoiUEXD/VnCiC85UEU4Zofq33mG+l+8wppc6hnlXyAh/MuC6 2drpaF1p7tsFqIpvRUVY2Gt+oa3rliXmOhmNc= Received: by 10.86.68.20 with SMTP id q20mr6404310fga.2.1216737467745; Tue, 22 Jul 2008 07:37:47 -0700 (PDT) Received: by 10.86.97.3 with HTTP; Tue, 22 Jul 2008 07:37:47 -0700 (PDT) Message-ID: <10845a340807220737v47c7ed5dm37d272007ff33521@mail.gmail.com> Date: Tue, 22 Jul 2008 15:37:47 +0100 Reply-To: RQuadling@GoogleMail.com To: "Rodrigo Saboya" Cc: internals@lists.php.net MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_8550_17561950.1216737467744" Subject: [PHP-DEV] Modify language grammar to allow commas to skip defaulted parameters. From: rquadling@googlemail.com ("Richard Quadling") ------=_Part_8550_17561950.1216737467744 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2008/7/22 Richard Quadling > > > 2008/7/22 Rodrigo Saboya > > Evan Priestley escreveu: >> >>> This was floated in 2003 but had weak advocation and didn't seem to come >>> to a decisive resolution: >>> >>> http://marc.info/?l=php-internals&m=106685833011253&w=2 >>> >>> Basically, the proposal is to modify the grammar to allow trailing commas >>> in function and method calls, so this becomes a parseable PHP construct: >>> >>> f(1, 2, 3,); >>> >>> This patch applies only to function and method calls; it does not apply >>> to function or method definitions. It also does not allow the degenerative >>> case of "f(,)". >>> >>> The real value of relaxing this rule is in nontrivial cases that span >>> across multiple lines: >>> sprintf( >>> 'long example pattern with %d conversions: %s', >>> $several, >>> $conversions >>> ); >>> >>> >> You could just do this: >> >> sprintf( >> 'long example pattern with %d conversions: %s' >> ,$several >> ,$conversions >> ); >> >> I really don't see a great benefit here, and as you pointed out it would >> make code written with trailing commas incompatible with previous versions >> of PHP. >> >> -- >> Rodrigo Saboya >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > Just thinking of other languages that allow you to skip params simply by > using commas. Whilst this isn't supported in PHP, allowing a trailing comma > and skipped parameters could look quite interesting! > > foo(,,,,,,,); > > > I must admit, I get stung with this in JS when I'm building AJAX option > sets through Prototype for IE (I think like arrays in PHP which allow > trailing ,), but I soon learned to do it properly. > > I don't see this as a huge advantage. > > Regards, > > Richard Quadling. > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > Actually, would allowing PHP to skip defaulted parameters be a better facility to add? function foo($opt1 = Null, $opt2 = Null){} foo(,True); Hmm. Doesn't look good does it. But, useful. Having to supply the default value if you don't want to override the default is sort of counter-intuitive. Suppling nothing should equal the default value. Regards, Richard. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" ------=_Part_8550_17561950.1216737467744--