Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56775 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15196 invoked from network); 4 Dec 2011 23:28:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2011 23:28:32 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.49 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.49 mail-qw0-f49.google.com Received: from [209.85.216.49] ([209.85.216.49:62979] helo=mail-qw0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 99/C0-08737-F120CDE4 for ; Sun, 04 Dec 2011 18:28:31 -0500 Received: by qadc16 with SMTP id c16so596967qad.8 for ; Sun, 04 Dec 2011 15:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=6aJPOEaUKNdwVAyuWXFe0yK99836M0IX4alPzp5nQ40=; b=v2GQ0uwkRN1UGPh5MCc/IIZN0Qs7eMUrkWLZn5nZj848ZkByW08YyFY8Cxr5M6uAK+ GnNB2JNCV9XV5uFYGPZnAHD3jYIpfFZvAdhwjmHzf7X4xSy7+PgY4uOmhT6GX13FI0nZ ooIAr/kPzL55YNMq8/2/3XOTx5DEBtIrnniJ4= MIME-Version: 1.0 Received: by 10.224.31.66 with SMTP id x2mr5978914qac.27.1323041308945; Sun, 04 Dec 2011 15:28:28 -0800 (PST) Received: by 10.229.212.5 with HTTP; Sun, 4 Dec 2011 15:28:28 -0800 (PST) In-Reply-To: <1323017742.18817.3.camel@guybrush> References: <4EDA4989.2010702@akbkhome.com> <1323017742.18817.3.camel@guybrush> Date: Mon, 5 Dec 2011 00:28:28 +0100 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Alan Knowles , PHP Internals List Content-Type: multipart/alternative; boundary=20cf302075903e2d1204b34c8f2e Subject: Re: [PHP-DEV] Fixing string offsets of strings. From: tyra3l@gmail.com (Ferenc Kovacs) --20cf302075903e2d1204b34c8f2e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2011/12/4 Johannes Schl=C3=BCter > On Sun, 2011-12-04 at 00:08 +0800, Alan Knowles wrote: > > This patch is a start. > > > https://bugs.php.net/patch-display.php?bug_id=3D60362&patch=3Dfirst_effor= t_to_fix_this&revision=3Dlatest > > > > It's been quite a while since I hacked on the engine, so the patch only > > works reasonably well.. (see the FIXME on the tests at the bottom of th= e > > patch.) > > > > The patch changes the following: > > * $s =3D "string"; $s['offset'] -- produces a warning (and returns a= n > > empty string) > > * $s =3D "string"; $s['1'] -- works as before.. > > * $s =3D "string"; $s[true] $s[false] $s[0.1] -- give a notice (cast= it > > to an int if you want to get rid of the notice) - however work as befor= e. > > * changes the warning on invalid indexes to say "Uninitialized or > > invalid" rather than just "Uninitialized" > > * fixes most of the related tests > > I think it's bad to add another set of casting rules to the language. > I'd prefer splitting the string offset operator from array offset. > > > $a =3D [0,1,2,3]; > $s =3D "string"; > > $a{0}; // wrong > $s{0}; // ok > $a[0]; // ok > $s[0]; // wrong > > Yes, something like this has been discussed before, back and forth and > doing this is too late for 5.4, but let's look to 5.5. > > this would have a much bigger impact than the currently proposed change (more people use [] than $foo['bar'] where $foo is a string. and while I think this would make the language much more cleaner, and explicit, this would be a major U-turn. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --20cf302075903e2d1204b34c8f2e--