Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73720 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60849 invoked from network); 17 Apr 2014 14:18:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2014 14:18:07 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.217.172 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.217.172 mail-lb0-f172.google.com Received: from [209.85.217.172] ([209.85.217.172:45049] helo=mail-lb0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/F2-39661-E92EF435 for ; Thu, 17 Apr 2014 10:18:06 -0400 Received: by mail-lb0-f172.google.com with SMTP id c11so427199lbj.31 for ; Thu, 17 Apr 2014 07:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=J3RjvFMJQJ//OmfHCLTgq2FmbB8W9qf1KSBiaq+h1+s=; b=q3lckLuaHI62RN0tP/fNRtrQtZ2eA/Y+osA+jMcpTnsPSpwQ4fbzjhe5Z65bi9XFVF S2nTgU2XXBVypqxsJbrjuHxn6FzfTSLz5+12CGMDXgxw0w/AkJJ+4aY8pikZrblaFV/j uxuBf2zDiokAbF7SPG9aB8k2TzNAXP9SeDlP8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=J3RjvFMJQJ//OmfHCLTgq2FmbB8W9qf1KSBiaq+h1+s=; b=RsKTYLoamZwepiJo7BACXkn+V6OwUBfpLI89LkosoufgHxiUAtBiaSyk3B2YW4R8eJ hk2epx4oeClrcnp+ymkEVXLIU5hVVqhPtfFDwuYNcXv1EbM2mxJBT4RGk6WIBOO1GaYK 4tnPmYwst20wjEHZ5/5w0xo+FVyAeZAP6ZIY11TtD6ZTb9K3EUA+1mcw4UfCK8PJ0A87 JZv8jymaEnixm6W4C7p+HX8uQgkM943yTq+V5odWFzQ61PUi5NCKDfeDveWj/cU3dhu8 Rlp/FkHKFqh8dJVzUCXPAs16o5vKQWT+G763Oi5Ya4J8VBxuv4AS4fTIwYWxXmSsJgO3 aN6A== X-Gm-Message-State: ALoCoQm74VqeOAHrskAGgzSF9kXQP+Xz8lP7mx243QU2zHLqDyggusZRRxDT7l9IjFzPf88rV3ih MIME-Version: 1.0 X-Received: by 10.112.52.104 with SMTP id s8mr7295850lbo.7.1397744283441; Thu, 17 Apr 2014 07:18:03 -0700 (PDT) Received: by 10.152.87.80 with HTTP; Thu, 17 Apr 2014 07:18:03 -0700 (PDT) In-Reply-To: <1397744009.2829.3212.camel@guybrush> References: <1397744009.2829.3212.camel@guybrush> Date: Thu, 17 Apr 2014 17:18:03 +0300 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Leigh , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Negative string offsets From: narf@devilix.net (Andrey Andreev) Hi, On Thu, Apr 17, 2014 at 5:13 PM, Johannes Schl=C3=BCter wrote: > Hi, > > On Thu, 2014-04-17 at 13:01 +0100, Leigh wrote: >> What are peoples thoughts on allowing negative string offsets, that retu= rn >> characters from the end of a string. > > I'm +/-0 on this. But mind: Current form makes it simpler to find bugs > when miscalculating the offset. Allowing negative offsets gives harder > to debug results. Additionally I wonder how often this is actually > needed, thus justifying to change the language rules. > > johannes For example, every time you need to check for a filename extension, last segment of a path, etc. When I need that, I always endup with substr(), strrchr() or explode(), end() ... both are suboptimal. Cheers, Andrey.