Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71760 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2970 invoked from network); 29 Jan 2014 22:45:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jan 2014 22:45:21 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.50 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.50 mail-wg0-f50.google.com Received: from [74.125.82.50] ([74.125.82.50:39149] helo=mail-wg0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D9/C8-52228-08489E25 for ; Wed, 29 Jan 2014 17:45:21 -0500 Received: by mail-wg0-f50.google.com with SMTP id l18so4764649wgh.17 for ; Wed, 29 Jan 2014 14:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=rHNluFKtdysB47zu2ukWebFt04Gnen/o+ae9fmr/JOM=; b=mJcLtD/2Nj6zMcUfk9e5lgety6TYZ9UQjW0wKZAWjTTlNVQaGPWSCEZCebX/yfxu+v /oTmXndb/sBg32YmdpQ+8NxbMyg4TaoeyeSwbczm4fdhiA1LY+hXqIkloI4+cMgwykiD O6qxixN/l3XeVAmIld60WsKUUugPdaPR5aXud4Z9UHLnE0zHMc4ChaHIsWOS0WzeHABb 7LwNXptbQs/SB72myCUCFHJRzk+SEXhOIalO72XvmI4mDAX9iWsLi4j29DZdOvNXORbq UprC8snijH7BHFUI7YF208P9Fq4B7uw+esB4+xc3oe/1AA7V8EOT/ndIBfu7dChcfNIw PTVw== X-Received: by 10.180.210.171 with SMTP id mv11mr7410290wic.44.1391035517581; Wed, 29 Jan 2014 14:45:17 -0800 (PST) Received: from [192.168.0.2] (cpc19-brig17-2-0-cust25.3-3.cable.virginm.net. [81.101.201.26]) by mx.google.com with ESMTPSA id gd5sm45501353wic.0.2014.01.29.14.45.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 14:45:12 -0800 (PST) Message-ID: <52E98472.5040206@gmail.com> Date: Wed, 29 Jan 2014 22:45:06 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: <7E.A3.39789.25841E25@pb1.pair.com> <12.A5.39789.B7851E25@pb1.pair.com> <52E16E01.7070401@gmail.com> <52E1BDB0.6050406@garfieldtech.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: [PHP6] Function name consistency From: rowan.collins@gmail.com (Rowan Collins) On 29/01/2014 14:55, Levi Morrison wrote: > On Thu, Jan 23, 2014 at 6:11 PM, Larry Garfield wrote >> If we're going to do anything, be aggressive and far-reaching with it. >> Build a proper language-level OOP design for string/array manipulation. >> > This is a completely honest, sincere question: Why should the language > itself use an object-oriented design for everything it provides? > Well, the reason that's most relevant to this discussion is that it's an excuse for a clear distinction between the old and the new. For instance: join() is an alias of implode(), which can take arguments in either order, or take only one argument; split() is a deprecated regex function not to be confused with explode(), which always takes (at least) 2 arguments, in a set order. Those function names have got to retain at least some of their behaviour - or be removed permanently - for as long as we still consider it the same language. However, with an "object-like" string interface you have a completely blank slate to design a clean interface alongside the old functions: $string->split('x')->join('y') perhaps. Another inconsistency often complained about is argument order; for a lot of operations, one parameter is the natural "subject" of the action, so you could have $array->map($function), $array->filter($function) rather than array_map($function, $array) and array_filter($array, $function). The downside, I admit, is it might "feel less like PHP". But there's a lot of object-oriented PHP out there where this would look quite at home. The only other way I can think of making a clean break from the messes in the current global namespace is to make new *namespaced* versions of the basic functions, like string\split, array\join, etc. Maybe even put all the existing functions into a legacy\ namespace which you could "use", although that might be a bit of a pain to work with. But unlike OO, that leaves us with potentially more to type for the new names than the old, which seems a shame. Basically, adding OO-style could feel like a proper tidy-up, rather than just re-painting a few bits that are easy to reach. -- Rowan Collins [IMSoP]