Re: Re: Str enhancement, final run
| From: | Cynic | Date: | Sat, 14 Jul 2001 23:13:04 +0000 |
| Subject: | Re: Re: Str enhancement, final run | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-60039@lists.php.net to get a copy of this message | ||
Hi there,
excuse my ignorance, but could someone provide me w/ some
hints as to the origin of this thread? I must've missed it
(just returned from vacation). Since I haven't seen prior
messages in this/related thread(s), I might be off base here.
Sorry if this is the case.
Now, some time ago (>1.5y) when I began exploring PHP and
stumbled upon something unintuitive (had to do w/ strings
being similar to arrays but not completely equivalent...)
Andi told me strings would be eventually made more different
from arrays.
Now, I might be the only one, but I actually like the idea of
equivalence of strings and arrays. For example, I'd like to
be able to foreach() a string just like it was an array (last
time I checked the behavior was st. like 'string' being used
as if it was array('string') - I'd prefer
array('s','t','r',
'i','n','g').
As for the Andre's suggestions, I like Python's ranges in both
lists and strings (they use colon instead of two dots). I
some details of it unintuitive, but don't remember what it was
exactly as it's been some time since I touched Python though.
I can look it up if anyone's interested.
Oh, where can I subscribe to engine2@lists.zend.com? Seems like
that's where the fun is. :)
At 18:38 7/10/2001, Andi Gutmans wrote the following:
--------------------------------------------------------------
>At 06:00 PM 7/10/2001 +0200, André Langhorst wrote:
>>As it were Andi's last words, is it the finial decison now just to implement $foo{x} to
>>retrieve a single char?
>>I'm asking this again, because it will be irreversible because it is not compatible
>>with substr($foo,x) == $foo{x}!!!
>>And as I still do not agree that substr($foo,4,6) should be better than
>>$foo{4,6} I now have another (taken and modified from Zeev or Andi) offer, which *is
>>intuitive*:
>>
>>What about the range proposals? $foo{4..6} where $foo{6..} would mean to the end, no
>>negative numbers, nothing else but at least that would simplify string processing a bit (although I
>>am still in favor for the substr() solution).
>>
>>I think even Zeev would agree that this is intuitive ;)
>>So far we have:
>>
>>$foo{x} get char at pos x
>>$foo{x..} get chars from pos x to the end
>>$foo{x..y} get chars from pos x to y
>
>This option looks nice but I don't like the extensions mentioned below. I still think that
>people who need more complicated stuff can use substr(). But I know many don't agree with me so
>I prefer to wait a while with the discussion until we start advancing a bit in the Engine 2
>implementation and then we will also have more of a technical basis to judge not only what is nice
>but also what is technically feasible.
>The only thing I think is pretty sure is that $foo{x} will work :)
>
>Andi
>
>
>>Now what if we do not know the position of the last character?
>>
>>$foo{x..-5} get chars from pos x to the minus 5
>>I tried to interprete this differently but I failed, isn't this called intuitive?
>>
>>As an alternative we even modify it to
>>$foo{x..|} and $foo{x..|-4}
>>if anyone feels better with it...
>>
>>Comments welcome,
>>andré
>>
>>ps. I do not remember the engine2 email address, if anyone could forward it...
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
>For additional commands, e-mail: php-dev-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
- Book of Installation chapt 3 sec 7