Re: deprecation status of $str{42} versus $str[42]
| From: | Arvids Godjuks | Date: | Mon, 16 Jun 2008 06:20:20 +0000 |
| Subject: | Re: deprecation status of $str{42} versus $str[42] | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38267@lists.php.net to get a copy of this message | ||
2008/6/14 Chris Stockton <chrisstocktonaz@gmail.com>:
>
> I personally have always used {} for string offsets because it just felt
> right. [] seems like it is for arrays, for me, using it on strings makes me
> feel dirty.
>
> Could we maybe visit some of the ideas you have had with {} syntax offering
> some benefit? That I do not completely understand and would be nice to know
> what you mean.
>
> Maybe something like built in substr? since it wouldn't break existing use
> of {}, tough thing is the ambiguity between {1} regular and {1} substr,
> dunno:
> $str = "abcdef";
> $result = $str{1}; // returns b, but substr would be something like bcdef
> $result = $str{1, 2} // returns bc, this we know what to return for sure
> $result = $str{1,} // maybe to make up for lack of {1} returning remaining
> portion, its a little ugly almost feels like a syntax error
>
> Just trying to figure out how you could have technical benefit with it,
> maybe you just meant performance optimization or something.
>
> -Chris
>
String is an array of chars, always was and is such in any programming
language. So I see argument for {} as missing knowledge for some programming
basics.
And I don't understand why are you arguing on this. This was decided for
removal long ago - so just do it.