Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51791 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73061 invoked from network); 2 Apr 2011 11:38:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Apr 2011 11:38:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=jacob@oettinger.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jacob@oettinger.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain oettinger.dk from 209.85.161.42 cause and error) X-PHP-List-Original-Sender: jacob@oettinger.dk X-Host-Fingerprint: 209.85.161.42 mail-fx0-f42.google.com Received: from [209.85.161.42] ([209.85.161.42:45383] helo=mail-fx0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/27-09874-CAA079D4 for ; Sat, 02 Apr 2011 06:38:21 -0500 Received: by fxm1 with SMTP id 1so3421919fxm.29 for ; Sat, 02 Apr 2011 04:38:17 -0700 (PDT) Received: by 10.223.33.80 with SMTP id g16mr1531352fad.125.1301744297788; Sat, 02 Apr 2011 04:38:17 -0700 (PDT) Received: from [10.182.22.248] ([213.55.72.13]) by mx.google.com with ESMTPS id 17sm1062688far.43.2011.04.02.04.38.14 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 02 Apr 2011 04:38:16 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii In-Reply-To: <4D94C380.2070402@lerdorf.com> Date: Sat, 2 Apr 2011 14:38:10 +0300 Cc: Martin Scotta , internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <7277ABA7-4B48-49FC-8974-512D4341CCC9@oettinger.dk> 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> To: Rasmus Lerdorf X-Mailer: Apple Mail (2.1082) Subject: Re: [PHP-DEV] Adding a more logical string slicing function to PHP From: jacob@oettinger.dk (Jacob Oettinger) On Mar 31, 2011, at 21:10 , Rasmus Lerdorf wrote: > On 03/31/2011 10:58 AM, Martin Scotta wrote: >> I think it's time to stop thinking in terms of "functions" and move >> forward to "abstractions" >>=20 >> $s1 =3D 'string'; >> $s1->contains($s2);=20 >>=20 >> $s1->indexOf($s2) =3D=3D=3D strpos($s1, $s2); >>=20 >> Why can't the strings be exposed as pseudo-objects ? users can choose = to >> use them as a regular strings or by calling methods on it. >=20 > 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? Sounds interesting. A few thoughts: The new "methods" could be implemented as functions that accept the = string or array as their first argument. Thereby allowing them to be = called as functions too. If the new methods are functions. Maybe they should be defined in the = \string and \array namespaces. This would allow a fresh start in naming = string and array functions, and allow addressing argument ordering = issues. It would of curse also open endless discussions on which = functions to include and the naming of these. If the new string and array functions were defined in some namespaces. = Would it be possible to allow extending the string and array "classes" = by defining more functions in those namespaces in userland and/or = extensions? Should the new string functions be multibyte character set aware? Should the above be generalized so that the -> operator can be used on = any simple type, and if the called "method" exists as a function in the = types namespace, it should be called. This would break the task into two = parts. !) changing php to attempt calling functions in a certain = namespace for each simple type. 2) Writing extensions that create = functions for each type, string and/or array would be obvious starting = points.=20=