Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61325 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63588 invoked from network); 16 Jul 2012 23:27:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 23:27:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajfweb@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajfweb@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: ajfweb@googlemail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:36045] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/00-62735-663A4005 for ; Mon, 16 Jul 2012 19:27:34 -0400 Received: by wibhq12 with SMTP id hq12so2647075wib.5 for ; Mon, 16 Jul 2012 16:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=i9/RRhRnbfv7Yj5r/JnsStRfo/qgSHgBEyvdFsn0F0k=; b=LcyiuWintqle+6LqhA/TT73l7SprDdUNSo2TGGz9LB4lJ+lxKuqCCSiIq2/AkCctPG e/eSYsZ/bSQl3pH/1fW41g37QN+4XGdYbKZAIGHisUYdLPib0shJYqGywce/ARz0iQHG gB/N734AZs33PRQ/DObxpHn4GB051IzBkUh8R/Zak5cqq0NSP1wcDVIP6qheidGe5dg7 P+cX5prsIE5zqJGx2HvduAxs14wesvZlsEQfhUjy9VU0Hok0B0/eBr2VKhVsn4XAbAti bOymcHzdb3PMhevwki6Cg+tHnriIIN12WYFFrGXqFSCzGCYA/ZiJXnI2YcUYdw2zBZZv CpvA== Received: by 10.180.78.2 with SMTP id x2mr311890wiw.10.1342481251001; Mon, 16 Jul 2012 16:27:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.160.16 with HTTP; Mon, 16 Jul 2012 16:27:10 -0700 (PDT) Date: Tue, 17 Jul 2012 00:27:10 +0100 Message-ID: To: internals Content-Type: text/plain; charset=UTF-8 Subject: Pseudo-objects (methods on arrays, strings, etc.) From: ajfweb@googlemail.com (Andrew Faulds) 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? -- Andrew Faulds (AJF) http://ajf.me/