Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61451 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96181 invoked from network); 19 Jul 2012 00:10:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 00:10:55 -0000 Authentication-Results: pb1.pair.com header.from=davidkmuir@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=davidkmuir@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.42 as permitted sender) X-PHP-List-Original-Sender: davidkmuir@gmail.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:49549] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/60-22428-E8057005 for ; Wed, 18 Jul 2012 20:10:55 -0400 Received: by yhoo21 with SMTP id o21so2557479yho.29 for ; Wed, 18 Jul 2012 17:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=V1liKXi/dAJ5c9AK+BTE7Wy7NJ/Hn8Ke294fH8bISco=; b=cVR/IaPX7XOlQAdQUFJUmvcJtMpzdsdutH6VdPoRdoslD/vfXp35gg0vjZSlrFcKwg 5RV7OJaAVimzbnssxv1q2rNBrG1hofHOmU0r6WDr3IBIdF2j9mIsXn/fy17t/ER5RoVb 0xumkqkL1kAi5tAdlQpjtjwvXhRW5t3lRNW94QClDEUAX2q8/mXLCgc++OJvFiLTtPXq enZAyp8B7jtMTuk1HLkfGXvSTtES8D1Zzv5Sb4sKKMW0Ukkl/W5cdSKY8bPX/TMWtAXr pVn1bQV+9sOwniitdKDmmUAoAsE4umXT+w/xGCpVbAZwSNlSfEOTzJObbK7h9NuVWqQp kixA== Received: by 10.66.82.228 with SMTP id l4mr3488253pay.41.1342656652023; Wed, 18 Jul 2012 17:10:52 -0700 (PDT) Received: from [192.168.1.181] (tmwpho1.lnk.telstra.net. [110.142.207.74]) by mx.google.com with ESMTPS id he9sm544908pbc.68.2012.07.18.17.10.49 (version=SSLv3 cipher=OTHER); Wed, 18 Jul 2012 17:10:51 -0700 (PDT) Message-ID: <50075090.3020003@gmail.com> Date: Thu, 19 Jul 2012 10:10:56 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Rasmus Lerdorf CC: Pierre Joye , Stas Malyshev , internals References: <50059AF8.5050805@sugarcrm.com> <5005CB58.2020601@sugarcrm.com> <50066724.6050901@sugarcrm.com> <50070538.10206@lerdorf.com> In-Reply-To: <50070538.10206@lerdorf.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Pseudo-objects (methods on arrays, strings, etc.) From: davidkmuir@gmail.com (David Muir) On 19/07/12 04:49, Rasmus Lerdorf wrote: > On 07/18/2012 01:02 AM, Pierre Joye wrote: >> hi, >> >> On Wed, Jul 18, 2012 at 9:35 AM, Stas Malyshev wrote: >>> Hi! >>> >>>> See the other answers, clear APIs, no more argument mess, cleanness. >>> Cleanness has nothing to do with pseudo-objects.You don't have to use >>> -> to have clean APIs, and using -> doesn't automatically make your APIs >>> clean. >> I really do not want to have a semantic discussion here. >> >> This syntax is sexy, allows us to clean our APIs, and is amazingly handy. > 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); > > other than being 2 characters longer to type? It's not like you can > remove abs() from the string pseudo-object, so you are essentially just > taking all the functions in the global namespace and attaching them as a > method to every pseudo-object. Is that clean? > > I think there is something we can do around this, but an argument of "it > is sexy and clean" needs to be backed up with some actual implementation > details that make sense. > > -Rasmus > Which is the needle, and which is the haystack? $pos = strpos($string, 'a'); $pos = strpos('a', $string); vs $pos = $string->pos('a'); $pos = 'a'->pos($string); I'm not proposing to use pos() as the method name, just showing an example that this syntax can be cleaner. David