Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Paul G
- Original Message - From: "Shane Caraveo" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 01, 2004 1:41 PM Subject: Re: [PHP-DEV] Re: Negative string offset support --- snip -- > Having my python hat on... > > There also is this whic

Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Shane Caraveo
Rasmus Lerdorf wrote: On Sun, 31 Oct 2004, moshe doron wrote: where the problem about 'taking it ever further'? I'm +1 for {-1} and more +1 for {-4,2} python likeness. That starts getting confusing. Having my python hat on... (some of this is just general comment after reading too much of this th

Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Sara Golemon
>> Substr_replace() for the purpose of changing one char is like using a >> tank for a fly swatter, it may work but it is extremely inefficient. >> > the example wasn't clear but I stated with substr_replace() there is no > need > for ranges in {}. > I like {$s,$l} and/or {$s:$e} for read, but I

Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Andrey Hristov
So, the example wasn't clear but I stated with substr_replace() there is no need for ranges in {}. Andrey Ilia Alshanetsky wrote: Substr_replace() for the purpose of changing one char is like using a tank for a fly swatter, it may work but it is extremely inefficient. Ilia Andrey Hristov wrote:

Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Ilia Alshanetsky
Substr_replace() for the purpose of changing one char is like using a tank for a fly swatter, it may work but it is extremely inefficient. Ilia Andrey Hristov wrote: just to mention that there is substr_replace() php -r '$a="abc"; var_dump(substr_replace($a, "d", -1));' IMO at least there is no

Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Andrey Hristov
just to mention that there is substr_replace() php -r '$a="abc"; var_dump(substr_replace($a, "d", -1));' IMO at least there is no need for range like $a{-4:2} Andrey Ilia Alshanetsky wrote: IMO {-1} syntax is not only faster but simpler to use then the equivalent substr() (for read) or $a[strlen(

Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread John Coggeshall
I honestly don't really care about the performance side of things, I'd be very surprised if this sort of calculation is going to be in the top 5 bottlenecks of an application. However, from a development point of view I do find $a{-1} a much shorter and cleaner way of calculating an end-of-string o

Re: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Ilia Alshanetsky
IMO {-1} syntax is not only faster but simpler to use then the equivalent substr() (for read) or $a[strlen($a) - 1] (for write). While my reasons are primarily performance based, I think that most people would find the {-1} simpler to use as well. Ilia Sterling Hughes wrote: i hope not. this

RE: [PHP-DEV] Re: Negative string offset support

2004-11-01 Thread Ford, Mike
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 30 October 2004 02:03, Andi Gutmans wrote: > Nah that patch won't do because it'll effect [] also. > It's more complicated than that. I've tried separating them in the > past and

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Derick Rethans
On Sun, 31 Oct 2004, Sterling Hughes wrote: > i hope not. this should be about what's cool for developers, the > speed increase is not a compelling reason.. the debate is "does this > make code easier to read/write/maintain?" I think it doesn't, and > therefore am against it. And I agree with

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Sterling Hughes
i hope not. this should be about what's cool for developers, the speed increase is not a compelling reason.. the debate is "does this make code easier to read/write/maintain?" I think it doesn't, and therefore am against it. -sterling On Mon, 1 Nov 2004 03:04:45 +0100, Marcus Boerger <[EMAIL

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Marcus Boerger
Hello Wez, well it would. However 5.1 aims to be a major speed improvement and that's what the idea is about. best regards marcus Monday, November 1, 2004, 2:29:46 AM, you wrote: > Doesn't substr($a, -1) work ? > --Wez. > On Sun, 31 Oct 2004 17:45:03 -0500, Greg Beaver <[EMAIL PROTECTED]> w

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Greg Beaver
Wez Furlong wrote: Doesn't substr($a, -1) work ? I knew that looked funny, but couldn't figure out why for some reason, thanks for the good catch. Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Wez Furlong
Doesn't substr($a, -1) work ? --Wez. On Sun, 31 Oct 2004 17:45:03 -0500, Greg Beaver <[EMAIL PROTECTED]> wrote: > It would reduce the errors I inevitably get > whenever using a complex feature like substr(). The three choices: > > 1) substr($a, strlen($a) - 1); > 2) $a{strlen($a) - 1} > 3) $a{-

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Greg Beaver
Marcus Boerger wrote: Hello Rasmus, Sunday, October 31, 2004, 11:27:40 PM, you wrote: On Sun, 31 Oct 2004, moshe doron wrote: where the problem about 'taking it ever further'? I'm +1 for {-1} and more +1 for {-4,2} python likeness. That starts getting confusing. I assume that translates to the 3

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Marcus Boerger
Hello Rasmus, Sunday, October 31, 2004, 11:27:40 PM, you wrote: > On Sun, 31 Oct 2004, moshe doron wrote: >> where the problem about 'taking it ever further'? >> I'm +1 for {-1} and more +1 for {-4,2} python likeness. > That starts getting confusing. I assume that translates to the 3rd and > 4

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Rasmus Lerdorf
On Sun, 31 Oct 2004, moshe doron wrote: > where the problem about 'taking it ever further'? > I'm +1 for {-1} and more +1 for {-4,2} python likeness. That starts getting confusing. I assume that translates to the 3rd and 4th chars from the end of the string. And, to verify that I went and look

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread Zeev Suraski
At 08:02 30/10/2004, Ilia Alshanetsky wrote: Derick Rethans wrote: - Adding new language constructs in mini releases is IMO not the way to go as it will make it possible impossible to run script that use this new construct not even parse on PHP 5.0.x servers. Adding normal new functions does

Re: [PHP-DEV] Re: Negative string offset support

2004-10-31 Thread moshe doron
Derick Rethans wrote: On Fri, 29 Oct 2004, Andi Gutmans wrote: Yeah, I also thought the word "need" is a bit strong :) It's more like "syntactic sugar which is nice-to-have" As I just told Ilia on IRC, I think we should not add this (now) for a couple of reasons: - Adding new language constructs

Re: [PHP-DEV] Re: Negative string offset support: and arrays?

2004-10-30 Thread Markus Fischer
Ilia Alshanetsky wrote: I am well aware that at this point PHP has no separation between [] and {} as far as string offsets go. My initial suggestion was to add the support for negative offsets and not to limit it to a particular construct. Given that this is intended for strings only, I readily

Re: [PHP-DEV] Re: Negative string offset support

2004-10-30 Thread Ilia Alshanetsky
Andrey Hristov wrote: Andy mentioned that he tried in the past to separate {} and [] but after some unsuccess he left the idea of separating. So, the patch definitely won't be 2-3 lines of code. I am well aware that at this point PHP has no separation between [] and {} as far as string offsets go.

Re: [PHP-DEV] Re: Negative string offset support

2004-10-30 Thread Andrey Hristov
Ilia Alshanetsky wrote: Derick Rethans wrote: How can you *need* this, you can use substr() just fine. Almost no peace of functionality in PHP in unique, some extensions duplicate core/standard functionality and vice versa. Usually the "core" offers a simpler access to a resource and full pledg

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Ilia Alshanetsky
Derick Rethans wrote: - Adding new language constructs in mini releases is IMO not the way to go as it will make it possible impossible to run script that use this new construct not even parse on PHP 5.0.x servers. Adding normal new functions does not have this problem of course, as those scr

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Ilia Alshanetsky
Derick Rethans wrote: How can you *need* this, you can use substr() just fine. Almost no peace of functionality in PHP in unique, some extensions duplicate core/standard functionality and vice versa. Usually the "core" offers a simpler access to a resource and full pledged extensions gives the

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Sara Golemon
"Andi Gutmans" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Nah that patch won't do because it'll effect [] also. > It's more complicated than that. I've tried separating them in the past > and it was annoying (and didn't have time to finish it off). > > Andi > True... I should

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Greg Beaver
Derick Rethans wrote: On Fri, 29 Oct 2004, Greg Beaver wrote: Ilia Alshanetsky wrote: I am wondering what are people's opinions on adding support for negative string offsets that could be used to access data from the end of a string. Ex. $a = "123"; echo $a[-1]; // would print 3 I don't think we s

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Andi Gutmans
Nah that patch won't do because it'll effect [] also. It's more complicated than that. I've tried separating them in the past and it was annoying (and didn't have time to finish it off). Andi At 05:51 PM 10/29/2004 -0700, Sara Golemon wrote: > - Adding new language constructs in mini releases is

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Sara Golemon
> - Adding new language constructs in mini releases is IMO not the way to > go as it will make it possible impossible to run script that use this > new construct not even parse on PHP 5.0.x servers. Adding normal new > functions does not have this problem of course, as those scripts are > s

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Robert Cummings
On Fri, 2004-10-29 at 19:29, Derick Rethans wrote: > On Fri, 29 Oct 2004, Andi Gutmans wrote: > > > Yeah, I also thought the word "need" is a bit strong :) It's more like > > "syntactic sugar which is nice-to-have" > > As I just told Ilia on IRC, I think we should not add this (now) for a > coupl

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Robert Cummings
On Fri, 2004-10-29 at 19:29, Derick Rethans wrote: > On Fri, 29 Oct 2004, Andi Gutmans wrote: > > > Yeah, I also thought the word "need" is a bit strong :) It's more like > > "syntactic sugar which is nice-to-have" > > As I just told Ilia on IRC, I think we should not add this (now) for a > coupl

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Sterling Hughes
I think we should not follow this discussion on internals@ and instead we should have a subcommittee to study whether or not the word need was appropriate in the context of the substring operator, or whether in fact, "would be nice to have, but might be able to continue living" would've been a more

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Derick Rethans
On Fri, 29 Oct 2004, Andi Gutmans wrote: > Yeah, I also thought the word "need" is a bit strong :) It's more like > "syntactic sugar which is nice-to-have" As I just told Ilia on IRC, I think we should not add this (now) for a couple of reasons: - Adding new language constructs in mini releases

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Andi Gutmans
At 01:05 AM 10/30/2004 +0200, Derick Rethans wrote: On Fri, 29 Oct 2004, Greg Beaver wrote: > Ilia Alshanetsky wrote: > > I am wondering what are people's opinions on adding support for negative > > string offsets that could be used to access data from the end of a string. > > > > Ex. $a = "123";

Re: [PHP-DEV] Re: Negative string offset support

2004-10-29 Thread Derick Rethans
On Fri, 29 Oct 2004, Greg Beaver wrote: > Ilia Alshanetsky wrote: > > I am wondering what are people's opinions on adding support for negative > > string offsets that could be used to access data from the end of a string. > > > > Ex. $a = "123"; echo $a[-1]; // would print 3 > > > > I don't think