Regarding PHP6, string/array APIs

From: Date: Thu, 19 Jul 2012 08:05:35 +0000
Subject: Regarding PHP6, string/array APIs
Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Stas made a good point about need to start with new API, which then can be followed by syntactic
sugar.

So, we need some ideas to start with:

1. A lot of people told, that it would be a good idea to come with a written standard regarding
arguments order. I don't care what it will be, as long as it will be documented.

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'
    ?>

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

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


Attachment: [application/pgp-signature] Message signed with OpenPGP using GPGMail signature.asc

Thread (9 messages)

« previous php.internals (#61460) next »