Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21007 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71757 invoked by uid 1010); 2 Dec 2005 14:11:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 71742 invoked from network); 2 Dec 2005 14:11:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2005 14:11:38 -0000 X-Host-Fingerprint: 195.225.34.5 fw01.axit.nl Received: from ([195.225.34.5:1764] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 5D/E8-14828-91650934 for ; Fri, 02 Dec 2005 09:11:37 -0500 Message-ID: <5D.E8.14828.91650934@pb1.pair.com> To: internals@lists.php.net References: <3F.25.11378.CEA42834@pb1.pair.com> <018d01c5eeec$23949600$5c8be5a9@ohr.berkeley.edu> <497935ba0511211511l5867410dk577deb60b998a069@mail.gmail.com> <497935ba0511211512k4c8e1cb4r89cf1ffcd4ab7829@mail.gmail.com> <438254E6.2050903@prohost.org> <497935ba0511211609n675a3c3yf03cb5e5e97bb5bf@mail.gmail.com> <4382BDA2.4050806@php.net> <497935ba0511220024l492112f7nfe2c05d27d65e1a5@mail.gmail.com> <497935ba0511220024j4a189b94r667945241f1811f8@mail.gmail.com> <497935ba0511220159y14dc36cra39e28d7d617a03b@mail.gmail.com> <13067.64.241.37.140.1132675931.squirrel@www.quo.org> <21.D1.11378.F1096834@pb1.pair.com> <00b501c5f17d$c1259980$7d051fac@stumpy> <43905052.1070208@mjec.net> <84.B8.14828.0B550934@pb1.pair.com> Date: Fri, 2 Dec 2005 15:11:15 +0100 Lines: 149 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-Posted-By: 195.225.34.5 Subject: Re: [PHP-DEV] Re: Syntax in PHP 6 From: r.korving@xit.nl ("Ron Korving") forgive my copy/paste error: "imagecreatefromstring needs no change, except that it will officially be strPos()" should say: "imagecreatefromstring needs no change, except that it will officially be imageCreateFromString()" - Ron ""Ron Korving"" schreef in bericht news:84.B8.14828.0B550934@pb1.pair.com... > Nice start (your url (function list) doens't seem to work yet by the way). > > Just my 2 cents: > > I don't like the '2' at all. I'd rather see nltobr() and dectohex() than > nl2br() and dec2hex(). I do like the idea of loosing all underscores (but > I bet there will be quite a number of developers here who want to keep > underscores). Removing underscores though, would open 2 possibilities: > - studlycaps > - no more randomness in underscore usage in function names (as you so > wonderfully explained) > > Since function names are case insensitive anyway, it won't be a problem at > all, and it'll provide word-boundaries just like underscores do today: > > strPos() > arrayMerge() > isInt() > imageCreateFromString() > > changes to make this happen: > > create alias array_merge() for arrayMerge() > create alias is_int() for isInt() > strpos needs no change, except that it will officially be strPos() > imagecreatefromstring needs no change, except that it will officially be > strPos() > > The situation will end up 100% BC and aliases can be removed in PHP 7 or > later. > > - Ron > > > > "Michael Cordover" schreef in bericht > news:43905052.1070208@mjec.net... >> >> >> Sara Golemon wrote: >>> I say this with no degree of sarcasm or ill-will: Create a formal >>> proposal. >> >> Well, you asked for it ;). >> >> Goals: >> - remove confusion when a user thinks about a function's name >> - develop consistency throughout the language >> - be backwards compatible as much as possible >> >> The basic idea began as "rename confusing functions but keep their old >> names as aliases to the 'preferred' version with a view to eventually >> removing the old ones". Well, let's take a look at a few things. Using >> a little bit of counting code and get_defined_functions(), it appears >> that there are 510 internal functions containing underscores and 304 >> which don't (PHP 5.0.4). The obvious solution appears to be to change >> all functions to use underscores. >> >> I went through the function list in an attempt to do just that. Many >> functions convert reasonably well - chop() remains chop(), >> escapeshellarg() becomes escape_shell_arg(). A fair number, however, >> were not quite so friendly. Should fclose() and feof() remain as such or >> should they become f_eof() and f_close()? fileatime() to file_atime() or >> file_a_time()? Is basename one word or two? There are also a fair >> number of functions like nl2br() - nl_2_br() would be silly. >> >> It seems to me, therefore, that we should get rid of the underscores. >> Yes, this means changing a lot more functions around, but adding >> underscores will just make function names MORE confusing where there's >> ambiguity - and that's what we want to remove. It's one of the big >> complains about PHP, that ambiguity. Furthermore, we don't want to make >> substantial changes to function names - doing things like nl2br() -> >> nl_to_br() will confuse more people than necessary and may conflict with >> existing user-defined function names. >> >> So, let's list functions and replace out all the underscores. We get: >> http://mjec.net/php/functions.html >> >> Well, that's not actually consistent with PHP overall. cal_to_jd() >> becomes caltojd() - that should really be cal2jd() to stay consistent. So >> lets do that. And at this stage I also added some checking to make sure >> there were no functions being duplicated. Well, there was one - >> diskfreespace() is an alias of disk_free_space(). That is, however, the >> only internal conflict I could find. That listing is at: >> http://mjec.net/php/betterfunctions.html >> >> There are a few functions I think need actual renaming, for consistency: >> bindec() -> bin2dec() >> decbin() -> dec2bin() >> octdec() -> oct2dec() >> decoct() -> dec2oct() >> hexdec() -> hex2dec() >> dechex() -> dec2hex() >> Those are the only ones I can think of at the moment. If you can think >> of any more, please tell me. >> >> So, let's look at where we are now. We can rename all 510 >> underscore-containing functions to not using their underscores, a >> relatively easy transformation. Similarly, changing '_to_' to '2' before >> killing underscores is trivial. Those bindec() -> bin2dec() etc have to >> be done manually. Then alias the old versions to the new function names. >> >> So, if a user knows a function's name they don't have to worry about >> underscores any more. The language is consistent with respect to >> underscores - there aren't any. But you can still use all the old >> function names, so we retain BC. I believe the suggestion was to remove >> this by PHP 8, which sounds reasonable. >> >> What's wrong with this proposal? Well, a few things. Firstly, it >> doesn't make all function names intuitive - there's still the word order >> problem. Secondly, it's a hell of a lot of work to change 510 function >> names and then alias them. >> >> Well, the first one just needs someone to go through all 813 distinct >> functions (not 814 because diskfreespace() is in there twice) and note >> which order they're in, then reorder them. I'll do this when I've got a >> bit more time on my hands - probably early next week. >> >> The second bit is fair enough, yes. It might be automatable? I'm not >> sure and will look into this once I get a proper internet connection >> back. >> >> The One Big Argument against the more wide-spread use of PHP is that it >> doesn't have consistent function names. If this can be fixed, well, you >> bewdy, as we say in .au. All I have to remember is haystack, needle >> except in_array() and array_search(). >> >> And those are my two cents. >> >> -mjec >> -- >> http://mine.mjec.net/