Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61477 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57216 invoked from network); 19 Jul 2012 11:41:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2012 11:41:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajfweb@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajfweb@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.212.176 as permitted sender) X-PHP-List-Original-Sender: ajfweb@googlemail.com X-Host-Fingerprint: 209.85.212.176 mail-wi0-f176.google.com Received: from [209.85.212.176] ([209.85.212.176:57103] helo=mail-wi0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/F5-25752-D42F7005 for ; Thu, 19 Jul 2012 07:41:02 -0400 Received: by wibhn17 with SMTP id hn17so4857874wib.11 for ; Thu, 19 Jul 2012 04:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vrkTrvkpJPVRSFMTzJoHckgjdZa6QThrLBrC+TcfYxc=; b=kMGI/j4HU9i/5FNyUO1yEnktOk2QQxtlhzcuT3VG0G/E/p9UkiVecRHk8eool+XMZ3 DJcvtazcPdWHapJvhSY4wi39GgJSqhN+SoHZWeJyJxHNn6LpNBo9kKzpiGlgjhXtfvV6 gjBVkXjrHUeDMvoz1sCDZ/8sUbpGvXPbW4eFJwD2isHfdgvUofL8hXuxQ3c/W+dqbU1S 8TzIfnR+wuwBMS8Z6h63r4c++OsJ0UH7L5+SxNgzExmU9v5hwH3pxKrck2ludmEs2Qtr zLiISMOU0WVsuv3I30uqVMVSCSUV9oZnNQG+hDTk5J14FfhzrIwgOJj8i6OzRCDIrh0v SDzw== MIME-Version: 1.0 Received: by 10.180.91.228 with SMTP id ch4mr3998324wib.7.1342698058314; Thu, 19 Jul 2012 04:40:58 -0700 (PDT) Received: by 10.216.160.16 with HTTP; Thu, 19 Jul 2012 04:40:58 -0700 (PDT) Received: by 10.216.160.16 with HTTP; Thu, 19 Jul 2012 04:40:58 -0700 (PDT) In-Reply-To: <64223D01-8F4C-4B65-AD6C-5C425EC0EA68@gmail.com> References: <64223D01-8F4C-4B65-AD6C-5C425EC0EA68@gmail.com> Date: Thu, 19 Jul 2012 12:40:58 +0100 Message-ID: To: Alexey Zakhlestin Cc: internals internals Content-Type: multipart/alternative; boundary=f46d043c7fa2ce71c104c52d409e Subject: Re: [PHP-DEV] Regarding PHP6, string/array APIs From: ajfweb@googlemail.com (Andrew Faulds) --f46d043c7fa2ce71c104c52d409e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable One consideration: Should be a general array/string/int/float/bool API. PHP is weakly typed: therefore, say, reverse() would reverse a string OR an array. negate() would invert a bool, negate an int/float. slice() would slice a section of a string OR an array. max() would find maximum of an array, or max() of two numeric values, etc. If you get my meaning. These are all examples of course. Many functions would have to be type-specific (numeric, array/string, boolean, array, string), but they should be multi-type as far as possible IMO. On Jul 19, 2012 9:06 AM, "Alexey Zakhlestin" wrote: > Stas made a good point about need to start with new API, which then can b= e > 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: > > $src =3D 'SoUrCe'; > $result =3D lowered($src); // $result =3D=3D 'source', $src =3D=3D = 'SoUrCe' > $result =3D lower($srd); // $result =3D=3D true, $src =3D 'so= urce' > ?> > > 3. Speaking of implementation=E2=80=A6 Functions, which return slice of > string/array could be made to reference the same memory-areas as the sour= ce > strings/arrays. That is until the first modification, of course. Kinda > advanced copy-on-write semantics. I know something like that is implement= ed > in D http://dlang.org/d-array-article.html and Go > > 4. casting between strings and arrays of characters would be a great thin= g > to have too. this way, useful array-oriented functions could be applied t= o > strings --f46d043c7fa2ce71c104c52d409e--