Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51794 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93492 invoked from network); 2 Apr 2011 15:42:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2011 15:42:07 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 74.125.82.54 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 74.125.82.54 mail-ww0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:41382] helo=mail-ww0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/50-23967-EC3479D4 for ; Sat, 02 Apr 2011 10:42:06 -0500 Received: by wwd20 with SMTP id 20so5146640wwd.11 for ; Sat, 02 Apr 2011 08:42:03 -0700 (PDT) Received: by 10.216.195.202 with SMTP id p52mr2276292wen.75.1301758923365; Sat, 02 Apr 2011 08:42:03 -0700 (PDT) Received: from pc ([83.228.56.37]) by mx.google.com with ESMTPS id c54sm1473284wer.6.2011.04.02.08.42.00 (version=SSLv3 cipher=OTHER); Sat, 02 Apr 2011 08:42:02 -0700 (PDT) Message-ID: <57CF4B6187F84C31884CE0F70F8F70E2@pc> To: "Rasmus Lerdorf" , References: <4D92CC38.5040900@toolpark.com> <004301cbeee8$e54a8280$afdf8780$@com> <4D9387BE.4030808@divbyzero.net> <4D94984D.8060700@lerdorf.com> <4D94A111.7050501@moonspot.net> <520FB834-2614-4873-AC3B-0B2594B18471@roshambo.org> <4D94A350.70201@lerdorf.com> <4D94C380.2070402@lerdorf.com> Date: Sat, 2 Apr 2011 18:41:58 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 Subject: Re: [PHP-DEV] Adding a more logical string slicing function to PHP From: sv_forums@fmethod.com ("Stan Vass") > This is actually something I have been toying with a bit. Adding the > ability to call methods on both strings and arrays. I still don't like > the idea of making them real objects as the overhead and the amount of > code that would need to be changed in the core and in every extension is > daunting. Anybody out there have a patch along these lines? > > -Rasmus Glad to see pseudo-object methods for scalars/arrays brought up again. It'll improve workflow a lot. I want to ask/suggest two clarifications on this: 1) You said 'strings and arrays', I hope that's 'scalars and arrays'. As the current PHP semantics work, and with very minor exceptions, int/float works as a numeric string when passed to a string function, and numeric strings work when passed to a number function. I.e. those should work: $a = 1234; /* int */ echo $a->substr(1); // '234' $a = '1.23456'; /* string */ $a->format(2); // '1.23' This means the extension methods for primitives should be split in two groups: arrays (lists and maps) - one API set scalars (bool, int, float, strings) - one API set 2) Because the language currently has no scalar hinting (I know it's coming), IDE autocompletion of the extension methods may not work very well (unless the IDE assumes everything is a scalar unless hinted otherwise). Both hinting, incl. for method/function return types, and extension methods should be introduced together as they make each other more useful, than independently. Let me know what you think. Stan Vass