Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61327 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66953 invoked from network); 16 Jul 2012 23:58:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 23:58:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=adamjonr@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=adamjonr@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: adamjonr@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:48229] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/B0-62735-8BAA4005 for ; Mon, 16 Jul 2012 19:58:48 -0400 Received: by obfk16 with SMTP id k16so12068422obf.29 for ; Mon, 16 Jul 2012 16:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=fPaEuTqbfSkazwpEEIzI/90iJxx+Jbni/hglQtk49Ho=; b=gn12dHjURSnIUBEI1oI5dybYuCO2w9rkMhtIVhiiLCVf/C8aTbDT0f8q+Ja3MCWqBu lscgaVbTgQ/s0XJBLNsTDHx9yrSSkLQM7LrBljXTnrHsTi25iK+PsUsYFxhYHf5y9ws+ O5caRR7rjVaERAYSnETgUfa4F4QZUK6XrPUtIbJDe3bitvNozodTLiRj0IHpPbZaD+CA gEvAVAaw0Om2UwPVRyGrs03cugVsq0lHF7mGbiaQJe6PXaeG2HJX9VPI5IuBvCnUsTad N0KR9oOSCd9dMQvQq9q64vHT6ifXqhp687NvY+6IGhm8fkkfgPO5w6FdToey5BtKCghZ wZ5Q== MIME-Version: 1.0 Received: by 10.182.14.101 with SMTP id o5mr530946obc.1.1342483124703; Mon, 16 Jul 2012 16:58:44 -0700 (PDT) Received: by 10.76.116.168 with HTTP; Mon, 16 Jul 2012 16:58:44 -0700 (PDT) In-Reply-To: References: Date: Mon, 16 Jul 2012 19:58:44 -0400 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Pseudo-objects (methods on arrays, strings, etc.) From: adamjonr@gmail.com (Adam Jon Richardson) On Mon, Jul 16, 2012 at 7:27 PM, Andrew Faulds wrote: > Through its history, PHP has slowly become more object-oriented. While PHP has become more capable for OOP, it has also become more capable for FP, too. And, procedural programming is still a very strong influence. > I think PHP could benefit from making arrays, strings, integers, > floats, and possibly booleans, into "pseudo-objects". By this I mean > that they are not really objects (they are still primitive types and > keep their passing semantics), but they have methods. For instance, > instead of array_keys($array), one could do $array->keys(); If the pseudo objects keep their passing semantics, this could be a source of confusion. > Adding this would make PHP feel more modern and allow people to > embrace more object-oriented programming styles. As a bonus, it would > also give a chance to make the string/array/etc functions better and > more consistently named and possibly implemented. I'm not sure I would classify it as more modern or if we should be hoping more people embrace OOP. The language would feel more OO with these changes, but there are many programming paradigms that are are trending now (FP, AOP, DbC, homoiconic languages like Clojure, Lisp, and Julia have helped promote meta-programming, etc.) I like that fact that PHP falls back into a procedural paradigm nicely, whilst still allowing me to use OOP design patterns and FP techniques for the bulk of my applications. While I'd like to see more consistency within the core functions, I'm not sure this is the route to take. Adam