Re: Negative string offsets
| From: | Leigh | Date: | Thu, 17 Apr 2014 20:37:27 +0000 |
| Subject: | Re: Negative string offsets | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-73732@lists.php.net to get a copy of this message | ||
On 17 April 2014 15:13, Johannes Schlüter <johannes@schlueters.de> wrote:
> 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.
I really don't know how often it would be needed, the patch comes from my
own selfish reasons. I needed it today so I knocked something up. (I was
dealing with string padding). We already have functions that accept
negative offsets to produce similar behaviour, so I thought it might fit
in. If the consensus is that it does not fit, then I'm happy to leave it at
that.
On 17 April 2014 14:11, Christian Stoller <stoller@leonex.de> wrote:
>
> Generally I like this, but I think it's confusing and inconsistent in
> comparison to array-indiexes, as you can have an array like `array(-1 =>
> 'foo')`
I'm with Daniel on this one, I'd trust developers to know when they are
dealing with a string or an array.
On 17 April 2014 17:48, Daniel Macedo <admacedo@gmail.com> wrote:
> I warned this would lead to the Python syntax...
Of course, this is the php-bikeshedding list. I have to wonder though, do I
take this as "full python compat or gtfo", or just ignore it, and hope for
some actual responses on the issue under discussion.
On 17 April 2014 19:13, Arvids Godjuks <arvids.godjuks@gmail.com> wrote:
>
> Although the syntax and ability is for the most part usefull, people forget
> the unicode problem.
> What should we let it traverse? Bytes or characters? Right now it is bytes,
> but it is rarelly used and people use functions and mb_* for unicode.
>
> This can be discussed only when we have full unicode, before that it is
> useless and just generates a ton of problems and takes time implementing
> from other more usefull stuff.
>
> A giant -1 from me.
What unicode problem? The proposed behaviour is the same as is currently
implemented.
Not sure why you think string offsets are rarely used, my experience is
exactly the opposite.
I'm just going to go ahead and assume you think this thread is about
python-style slice syntax.
It is not.