Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71079 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70630 invoked from network); 12 Jan 2014 09:14:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2014 09:14:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=ingwie2000@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ingwie2000@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.215.174 as permitted sender) X-PHP-List-Original-Sender: ingwie2000@googlemail.com X-Host-Fingerprint: 209.85.215.174 mail-ea0-f174.google.com Received: from [209.85.215.174] ([209.85.215.174:65168] helo=mail-ea0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 96/00-04828-40D52D25 for ; Sun, 12 Jan 2014 04:14:45 -0500 Received: by mail-ea0-f174.google.com with SMTP id b10so2761276eae.33 for ; Sun, 12 Jan 2014 01:14:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=cr9vgYZ9pfCiIciGwJyOkB5SUOd557aCh820m7VcRac=; b=lgZ7YEE/VRftHix2VgzejfCDG/9Oy6T7zeLWwCeTc752kgcYqeAjmjQmjzyv/vvtd0 Uw+RBx2p18FbhlpezRDH4aLdaJbjLfAFLDZSaKsL3Eq2xnWoj56ozCu46CQt1eLWS2Wt nJ7ii7BgZrJYB/SF1gcIeZ3tmhmQ5RZulJvGu7XTnzr1VGB/b/s1S/QD0Eo/KPMLsHmK r0nmazm6NoJiyPpZ49MlVHxDBJ5dHgseOSi9af2Je+ESdiG2RelF8ZOFYAo76YUkMWvR /FYBxg3AHjYgx9u0RRWE2oDs4PsdasIXgeHbwLVNwCHdkPeiQinlYGBXT5y4t98Z6K38 J6QA== X-Received: by 10.15.31.196 with SMTP id y44mr8055457eeu.96.1389518081215; Sun, 12 Jan 2014 01:14:41 -0800 (PST) Received: from ingwies-air.speedport_w723_v_typ_a_1_00_098 (p5B152B51.dip0.t-ipconnect.de. [91.21.43.81]) by mx.google.com with ESMTPSA id o13sm29414826eex.19.2014.01.12.01.14.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 01:14:40 -0800 (PST) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.0 \(1822\)) In-Reply-To: Date: Sun, 12 Jan 2014 10:14:41 +0100 Cc: nikic@php.net, internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <581A185E-0F00-4B49-AA87-859D75E63BA2@googlemail.com> To: Patrick Schaaf X-Mailer: Apple Mail (2.1822) Subject: Re: [PHP-DEV] Revisiting the "Named Arguments" RFC From: ingwie2000@googlemail.com (Kevin Ingwersen) Am So. Jan. 12 2014 09:16:13 schrieb Patrick Schaaf: > First of all, I'd love seeing this feature in PHP, and it would be a = very > large incentive to upgrade to 5.6 asap when it would be included = (without > bugs of course :) >=20 Not just you! :) > I'd like to offer my thoughts on the open questions in the RFC: >=20 > Regarding Syntax at the call site, I feel that it is exactly right the = way > it is proposed / implemented now. That way mirrors most closely the = syntax > of static array definition, while saving some typing (omitting of = double > quotes) where key names do not clash with keywords. In fact, once > established, I would love static array initialization to also permit > nonclashing keys to omit the doublequotes :) >=20 > One question, given that syntax: would > $foo =3D 'bar'; > test($foo =3D> 123); > pass a named parameter named 'bar' ? That would be my visual = expectation, > and is what feels wrong about the alternate proposals. I wondered that too, and I think that is what the engine will do by its = own; resolving the variable into its value. Hence, this option won=92t = be possible; but that=92s ok iMO as it=92s pretty logical. > Regarding the separation of positional and named stuff when > packing/unpacking (the python *kw vs. **kw distinction) I feel that = would > be unnatural. There is no syntactic precedent in PHP regarding = notation, > and I think where desired, explicit code using array functions should > always easily be able to make the split in an obvious fashion. >=20 > Regarding signature violation, and clearly just as a personal opinion, = I > don't see LSP as a law of languages, but just as a good coding = practise. > Thus, I would be happy to just have the same runtime checks in place = for > ordinary functions, against the actual method called, with exactly the = same > error behaviour as for ordinary function calls, instead of an = additional > set of errors and/or warning coming from structural checking of child = and > parent methods. I think that's what the RFC / current implementation = does, > but the RFC seems unclear in that regard. +1 - agreed. We already have warnings and exceptions for things such as = BadFunctionCall etc. Why not just utilize these instead? That would just = save some work! :) > Finally, regarding internal functions and their arginfo and the naming = of > parameters there... in my imagination, that is the think that would = still > need the most work, and would tend to bikeshedding regading the = parameter > names set in stone in the process... Which leads me to the question = whether > that work wouldn't be best postponed: > - create variations of the arginfo declarations that explicitly say, = on a > function-by-function basis, whether named parameters should be = supported > - forbid use of named parameters with any function not yet modified = and > reviewed in that fashion > Personally, being able to use named parameters in our own userland > functions and classes, is much more important than use against = internal > functions, and postponing the feature altogether due to the internal > functions not being fit to accept named parameters, would be sad. Yeah, I agree. As plain C does not have =84real arrays=93 such as C++ = may offer, it would be ultra hard to code it in. I mean, it is already = quite uneasy to use scripted arrays within native functions=85or = Objects. Hence, I wouldn=92t really offer named arguments in that case, = as one=92d have to create a whole new argument parser and extractor, = which would mean even more changes on the actual engine to offer the = userland abilities to the =84devland=93. I agree to not change the C side too much from that point of view. Another thought i had was concerning the =3D> operator. It currently = is,as far as I know, used in two things: foreach and arrays. But another = suggestion on the page was mentioning a colon: test(word1:=93Hello=93, word2:=93Bar=93); Colons are currently only used, afaik, in =84shorthand=93 if-else = statements: $var =3D (isset($argv[2]) ? $argv[2] : null); And, in another token, its used for static calling: Fubar::meep(); So therefore, I would actually suggest using colons. It does quite mimic = the ObjC calling style, but it keeps the old-fashioned function style, = which I honestly prefer (besides, adopting an ObjC messaging style = syntax would be either ultra-hard or never accepted :D). Kind regards, Ingwie=