Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61326 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65351 invoked from network); 16 Jul 2012 23:45:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 23:45:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:45585] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/60-62735-A97A4005 for ; Mon, 16 Jul 2012 19:45:30 -0400 Received: by pbbrp12 with SMTP id rp12so11966366pbb.29 for ; Mon, 16 Jul 2012 16:45:27 -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 :cc:content-type; bh=xHNeZ+Y8NYHcQctk1b4S5rVcAl+yz6ayG6v3CY+j4bY=; b=aGCpw1bZk0FeRI4K1hnKec0xoP4az0OnlmmfWNSO8RXqh+Vdc8QYwcTb15tTVbbQIE F78D1eRkZfWz/wKzn3nbqG6UjG0yQMXl7KQbTgEr0cBGjaJIpSNNn6QGNuHJHwS2MsvI CDykkMCsk5p/7Rob0tROQg7Hu3+5yMJ9c8ffpF/v+EkmuKet0MsBLoH9oq50E3pYCuhZ F6TdB7XnIBH3/id+4f6lbMZnYJCl4zvOp9kuCoFDu3TKJcRViT7wo3ZKw6Oml14MTbZu r0zwQqWBrS7GTBjzU73sd31DoRlwpNNjPjXv17I1p/cFtJxD9PYIF85EGHgY97MsEjEC hqIA== MIME-Version: 1.0 Received: by 10.68.219.135 with SMTP id po7mr841597pbc.149.1342482327499; Mon, 16 Jul 2012 16:45:27 -0700 (PDT) Received: by 10.68.54.169 with HTTP; Mon, 16 Jul 2012 16:45:27 -0700 (PDT) In-Reply-To: References: Date: Tue, 17 Jul 2012 01:45:27 +0200 Message-ID: To: Andrew Faulds Cc: internals Content-Type: multipart/alternative; boundary=e89a8ff248193f730c04c4fb06bb Subject: Re: [PHP-DEV] Pseudo-objects (methods on arrays, strings, etc.) From: tyra3l@gmail.com (Ferenc Kovacs) --e89a8ff248193f730c04c4fb06bb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Jul 17, 2012 at 1:27 AM, Andrew Faulds wrote= : > Hi there, > > Through its history, PHP has slowly become more object-oriented. PHP > today has classes, interfaces, objects, namespaces, and so on. > However, much of the language's core functionality is entirely > procedural, composed of functions and constants, much of which are > badly organised and inconsistently named. > > 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(); > > 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 am working on an implementation of this for arrays, but I haven't > got very far. However, for someone that knows the Zend engine > internals, it does not appear to me that adding such things would be > very difficult. > > Thoughts? > > we have that brought up once or twice in the past, last time it was Rasmus who mentioned that it could be nice: http://marc.info/?l=3Dphp-internals&m=3D130159506720600&w=3D2 --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --e89a8ff248193f730c04c4fb06bb--