Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60187 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59863 invoked from network); 18 Apr 2012 12:17:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2012 12:17:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 213.123.20.125 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 213.123.20.125 c2bthomr07.btconnect.com Received: from [213.123.20.125] ([213.123.20.125:4526] helo=mail.btconnect.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/BA-03614-CC0BE8F4 for ; Wed, 18 Apr 2012 08:17:16 -0400 Received: from host81-138-11-136.in-addr.btopenworld.com (EHLO _10.0.0.5_) ([81.138.11.136]) by c2bthomr07.btconnect.com with ESMTP id HGM63980; Wed, 18 Apr 2012 13:17:13 +0100 (BST) Message-ID: <4F8EB0C9.3020205@lsces.co.uk> Date: Wed, 18 Apr 2012 13:17:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Firefox/11.0 SeaMonkey/2.8 MIME-Version: 1.0 To: PHP internals References: <4F8DF4B1.2040307@sugarcrm.com> <4F8E9E1E.8050207@lsces.co.uk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0303.4F8EB0C9.0059, actions=TAG X-Junkmail-Premium-Raw: score=7/50, refid=2.7.2:2012.4.14.215414:17:7.944, ip=81.138.11.136, rules=__MOZILLA_MSGID, __HAS_MSGID, __SANE_MSGID, __USER_AGENT, __MIME_VERSION, __TO_MALFORMED_2, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __CT, __CT_TEXT_PLAIN, __CTE, URI_ENDS_IN_PHP, __ANY_URI, __URI_NO_MAILTO, __CP_URI_IN_BODY, BODY_SIZE_3000_3999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS X-Junkmail-Status: score=10/50, host=c2bthomr07.btconnect.com X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0209.4F8EB0C9.0151:SCFSTAT14830815,ss=1,re=-4.000,fgs=0, ip=0.0.0.0, so=2011-07-25 19:15:43, dmn=2011-05-27 18:58:46, mode=multiengine X-Junkmail-IWF: false Subject: Re: [PHP-DEV] [RFC] skipping optional parameters From: lester@lsces.co.uk (Lester Caine) Daniel Macedo wrote: > I am sorry Lester, but you seem to be getting the "optional parameter" > backwards. > > You are supposed to use the optional parameters when it's up to the > library/function definition to determine it's value, not when the > value is what you want for this particular function call! > > What you seem to be currently reading from a function definition when > using it is i.e.: "This parameter's default is TRUE? That's what I > need it to be here, skip typing it!" > This is the wrong approach for proper design, and you will have a lot > of headaches when refactoring! > > If you use them*properly*, what you read when using the function call > is "I don't need/want to change the default value for this optional > parameter, use what the library determines!", this is the proper way > to use a function call with optional parameters, that will give you a > LOT less headaches! I'm reading things exactly has they are written ... If I am USING a later optional parameter, then with well written libraries I also often need to change the earlier optional ones. Since my IDE provides an overview of how the defaults have been defined I can check, but I *HAVE* been stung by changes of a default value in the library which then messed up operation requiring the optional parameter to be set. Adding the ability of also having to check earlier optional parameters just seems adding to the agro without any real gain! I'm not talking about MY use of this, but is inclusion without thought in library code. > The problem with the way things work currently, is that the default > value, is now*hard coded* into all function calls were you wanted to > use the default, but needed to define a latter optional parameter! > > Hence the proper use would be to either use a reserved word, or having > named parameters. > I personally think there's a place for having both. Yet another reason for wanting a LTS version of PHP that we can use without worrying about all these 'extras'. Named parameters have been discussed in the past, and not taken forward. If you NEED named parameters, simply use a parameter hash ... which is the normal practice for 'heavy' parameter passing anyway. Similarly if I could trust the library maintainers NOT to change a default, then 'default' might make sense, but to be honest trying to keep libraries working is as bad nowadays as keeping my own code working as well. I've just finished 3 heavy days making the bulk of the bitweaver code 'strict' safe. Much of the code still needs extra work, but the bulk of what I USE is now clean. NOW I have to do the same on the libraries that it uses ... In the absence of a GOOD guide to 'preferred practice' rewriting the bw code to include ALL the public/private additions will have to wait. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php