Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61522 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15103 invoked from network); 19 Jul 2012 21:42:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 21:42:07 -0000 Authentication-Results: pb1.pair.com header.from=ajfweb@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajfweb@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.212.182 as permitted sender) X-PHP-List-Original-Sender: ajfweb@googlemail.com X-Host-Fingerprint: 209.85.212.182 mail-wi0-f182.google.com Received: from [209.85.212.182] ([209.85.212.182:53087] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/2C-18983-E2F78005 for ; Thu, 19 Jul 2012 17:42:07 -0400 Received: by wibhq12 with SMTP id hq12so2538331wib.11 for ; Thu, 19 Jul 2012 14:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/2XPkaDvcnjs8LCqIlbq5DObcEbPOwvAeM5brKflvR4=; b=SFZ2D+ow5ytnhlZ3mMaQPRbwDqk87S2XvOcnLJi9Uyon1Ii9h2NUbLcTjMLm+tDYbZ 7gyD3NHw4IH0kGHq+eb1fDk0w89AUp0RjPdHKMC7wYSMiYmZzQKM8uKV7WSSbPbCXbZk lPcpmwxO/MWHhjVqi2++fpkqOtNyzXFQ7NgiShTHod1xDe+morwiKpMGTex4dW0P34tu 51MPXyEzGSKri8eVZ2RhvcRZxAcOYPz+N/UreDNNcL4TMS81PPoiHlWiu/qgeidGXrLN jDHUNnGuyfQc20/RVkQiDJXiecQ7l8ud20xExS7D2n9fudr/Hc5Fzu2NTVrCGnRtbcBR 9Dpw== MIME-Version: 1.0 Received: by 10.216.118.72 with SMTP id k50mr146380weh.224.1342734123763; Thu, 19 Jul 2012 14:42:03 -0700 (PDT) Received: by 10.216.160.16 with HTTP; Thu, 19 Jul 2012 14:42:03 -0700 (PDT) Received: by 10.216.160.16 with HTTP; Thu, 19 Jul 2012 14:42:03 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 Jul 2012 22:42:03 +0100 Message-ID: To: Sara Golemon Cc: internals Content-Type: multipart/alternative; boundary=e0cb4efa789a7989f404c535a6d9 Subject: Re: [PHP-DEV] Pseudo-objects (methods on arrays, strings, etc.) From: ajfweb@googlemail.com (Andrew Faulds) --e0cb4efa789a7989f404c535a6d9 Content-Type: text/plain; charset=UTF-8 I never said treat them as objects. I said give them methods. Not the same thing. And what do you mean by "technical debt"? On Jul 19, 2012 9:52 PM, "Sara Golemon" wrote: > > > On Mon, Jul 16, 2012 at 4:27 PM, Andrew Faulds wrote: > >> 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(); > > > How about just creating (in PEAR or PECL) a Php Type Library which lets > you write all the new code you want which treats all these things in a > Javaish OOP way, but leave PHP's functional roots alone? > > $str = new String("Foo"); > if (3 == $str->length()) echo $str->toUpper(); > > I think automagically treating actual non-objects as objects is just > asking for massive amounts of confusion. The technical debt PHP would take > on from doing something like this would be... painful. > > If you *really* feel strongly about it, then I'd suggest you grab > pecl/operator as a starting point and create an extension which hooks the > opcodes involved in method calls to route to scalar handlers instead of > producing the error message which they do now. If you want to get clever, > you might even make the prototype classes for the scalar handlers > extensible to override functionality in userspace, but don't tell anyone I > suggested that. :) > > -Sara > --e0cb4efa789a7989f404c535a6d9--