Hi! > 2. It would be really useful to have 2 versions of each function: one > which mutates the variable and one which returns the new variable. > > Example: > > <?php $src = 'SoUrCe'; $result = lowered($src); // $result == > 'source', $src == 'SoUrCe' $result = lower($srd); // $result == > true, $src = 'source' ?> >
I'm not sure I understand why. What's wrong with $src = lowered($src);? Also, when lower() returns not true? If there's a legitimate situation when it must return not true (I can't think of any, but maybe for more complex functions there is) what lowered() is supposed to do in the same situation? If there's none, why bother returning true? > 3. Speaking of implementation… Functions, which return slice of > string/array could be made to reference the same memory-areas as the > source strings/arrays. That is until the first modification, of > course. Kinda advanced copy-on-write semantics. I know something like > that is implemented in D http://dlang.org/d-array-article.html and > Go Strings are not modified in PHP (IS_STRING zvals can be modified but the actual string buffers aren't) so there's no actual "write" and thus no copy needed. But having this would require separate refcounting on string values, which may be a bit complicated to do. > > 4. casting between strings and arrays of characters would be a great > thing to have too. this way, useful array-oriented functions could be > applied to strings We already have it, it's str_split(). -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php