Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51779 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63287 invoked from network); 31 Mar 2011 18:40:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2011 18:40:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=birken@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=birken@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: birken@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:54130] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/B6-27840-89AC49D4 for ; Thu, 31 Mar 2011 13:40:25 -0500 Received: by vwl1 with SMTP id 1so2328563vwl.29 for ; Thu, 31 Mar 2011 11:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=FzyhMrIm5sHmh32a4XfwkAC0rho5RogQmAdcxBTNBlw=; b=UT9STZPW8zjm+8BrSy8TOf1nctbslj/Sq4ltUi3O1c7ewyZnZ3i5mp/QmxetuRDZue NZWoNXBf/CmXc05rakQH4Kpbz4tFsdmnWKKuXxScAOoVIbSQ6N7Krbfb7asOeQksZUER Fv/ELUe4je2pEM2qGLwSoqOPi4kT0RtdaqFtU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=RaWSyjri9aa3bmlCR4C08HAKCK+kuO8svmINhEVGiTWtGU1RM05CHdfYszhlJymtqL gbz1PENYgbeg3u0kJgC3KdAksPCm8HGRl7fPYUpVGC2QpMSdHqgaQ8bhxPly3Ik6FDkK 2GjXyXlNevgGZ9cV/c+gsuKINRYmfDvlkum58= MIME-Version: 1.0 Received: by 10.52.92.38 with SMTP id cj6mr3863844vdb.254.1301596821367; Thu, 31 Mar 2011 11:40:21 -0700 (PDT) Received: by 10.52.157.200 with HTTP; Thu, 31 Mar 2011 11:40:21 -0700 (PDT) In-Reply-To: <4D94C380.2070402@lerdorf.com> 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: Thu, 31 Mar 2011 11:40:21 -0700 Message-ID: To: Rasmus Lerdorf Cc: Martin Scotta , internals@lists.php.net Content-Type: multipart/alternative; boundary=bcaec50162c52daad4049fcba043 Subject: Re: [PHP-DEV] Adding a more logical string slicing function to PHP From: birken@gmail.com (Dan Birken) --bcaec50162c52daad4049fcba043 Content-Type: text/plain; charset=ISO-8859-1 On a somewhat related note (and going back a little to my original patch), languages like python and ruby allow slicing on array/string objects with $string_or_array[start:end] syntax. I think this would be really useful syntax in PHP as well (and would of course make the initial patch I submitted obsolete). The one thing I was hesitant about with my patch was polluting the global function space for PHP, and I think adding new and specific syntax to provide these things is much better. I have no idea how feasible it is given PHP's internal structure, but if it was possible I would be glad to try to write a patch for it. -Dan On Thu, Mar 31, 2011 at 11:10 AM, 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" > > > > $s1 = 'string'; > > $s1->contains($s2); > > > > $s1->indexOf($s2) === strpos($s1, $s2); > > > > 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. > > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --bcaec50162c52daad4049fcba043--