Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61497 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95422 invoked from network); 19 Jul 2012 16:02:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 16:02:29 -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:63054] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/42-18983-49F28005 for ; Thu, 19 Jul 2012 12:02:29 -0400 Received: by wibhq12 with SMTP id hq12so2263811wib.11 for ; Thu, 19 Jul 2012 09:02:25 -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=/1miRE/H4ryWuIa7eYw0I1PXStoTrlAMyAeO5IMrWGs=; b=RayAEL94E+RCEVsrVR/tv7C0xn+vbPYSJbMzGH9aKb4w7g4F2XsDHSaw/rE09E2EIv iBZtdMPZWV7FKR0ghrN/JEYCWVcR5fEFxo7zVQ2t3HYcV/8x+B+VAIDV6jKtQ17F8s0r MiT3ukzp7Mng9ZbLlbjbaH6jjahd4dBFK1rwh2bYY7X8spryWn2hiCSNdjWHlm+Wsqha WiIOu5N0io20dF667aDqaJfoNT1xzv3+XrfsoE6crHYxOAdpllA0WoRJrC8F+svtIqIH 4XT7i2lZTfxuzjRXWW3OwUvbExbf81Rvg0+SfDlrUPreCRl9VxSvcVG3JFGqM5HA10qL DdDQ== MIME-Version: 1.0 Received: by 10.216.240.196 with SMTP id e46mr1584571wer.224.1342713744902; Thu, 19 Jul 2012 09:02:24 -0700 (PDT) Received: by 10.216.160.16 with HTTP; Thu, 19 Jul 2012 09:02:24 -0700 (PDT) Received: by 10.216.160.16 with HTTP; Thu, 19 Jul 2012 09:02:24 -0700 (PDT) In-Reply-To: <50082C7E.4080400@lerdorf.com> References: <50059AF8.5050805@sugarcrm.com> <5005CB58.2020601@sugarcrm.com> <50066724.6050901@sugarcrm.com> <50070538.10206@lerdorf.com> <50082C7E.4080400@lerdorf.com> Date: Thu, 19 Jul 2012 17:02:24 +0100 Message-ID: To: Rasmus Lerdorf Cc: Pierre Joye , Stas Malyshev , internals Content-Type: multipart/alternative; boundary=e0cb4e43cff1ccc94504c530e7f5 Subject: Re: [PHP-DEV] Pseudo-objects (methods on arrays, strings, etc.) From: ajfweb@googlemail.com (Andrew Faulds) --e0cb4e43cff1ccc94504c530e7f5 Content-Type: text/plain; charset=UTF-8 We can have more consistent naming, at least. I like this idea even more now, it means we could have a set of universal operations: $bool->negate(); // true -> false $num->negate(); // 7 -> -7 $numericString->negate(); // "123" -> -123 $float->negate(); // 3.141592 -> -3.141592 $customVectorType->negate(); // (1, 0.5, -1) -> (-1, -0.5, 1) //etc. negate(); is just an example: that's usually done with an operator, I'm really thinking more of things like sort() here. But you get the idea. On Jul 19, 2012 4:50 PM, "Rasmus Lerdorf" wrote: > On 07/19/2012 12:25 AM, Pierre Joye wrote: > > hi Rasmus, > > > > On Wed, Jul 18, 2012 at 8:49 PM, Rasmus Lerdorf > wrote: > > > >> This makes no sense to me either. How does it let us clean the APIs? Can > >> you give an example? I have one: > >> > >> $a = -5; > >> $b = "-5"; > >> > >> echo $a->abs(); // Outputs 5 > >> echo $b->abs(); // should still output 5 > >> > >> What has been cleaned here over: > >> > >> echo abs($a); > >> echo abs($b); > > > > Heh, here is another example where it makes even less sense: time(); > > > > sigh. > > > > More seriously... we are not talking about these APIs and I am sure > > you know which one I refer to, like the string API and the like. > > Ok, so for the string API: > > $a = 1; > $a->strstr('1'); > > should still work. All the string API methods need to be available on > every pseudo-object regardless of the type. So I don't see any "cleanup" > here either. > > -Rasmus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --e0cb4e43cff1ccc94504c530e7f5--