Re: PHP 7 API naming conventions: str vs string

From: Date: Mon, 19 Jan 2015 15:57:19 +0000
Subject: Re: PHP 7 API naming conventions: str vs string
Groups: php.internals 
Request: Send a blank email to internals+get-80832@lists.php.net to get a copy of this message
Hi, On Sun, Jan 4, 2015 at 1:57 AM, Sara Golemon <pollita@php.net> wrote: > On Sat, Jan 3, 2015 at 3:42 PM, Nikita Popov <nikita.ppv@gmail.com> wrote: > > Or maybe be more explicit and use "cstr" for C strings. (For symmetry the > > zend_string type could become zstr.) > > > I personally prefer cstr/zstr for explicitness, but agree that the > main focus should be consistency. > Do you mean Z_STRVAL would become Z_CSTRVAL ? Argh... I would suggest that references to zstrings should always be prefixed with a 'z', no matter if it is 'zstr' or 'zstring'. This way, when you see 'str' or 'string' in a name, you know it cannot be a zend string. The only exception would be the 'zend_string' type itself but even 'zend_string' in function names should be replaced because you cannot know if the 'zend_' substring is just part of the function name or refers to the 'zend_string' type. Making a difference between 'str' and 'string' is too cryptic and not intuitive. And what about a new future string type ? Use 'st' or 'stri' :) ? ZVAL_STR would become ZVAL_ZSTR, for instance. Some may find it redundant but the 'Z' of ZVAL and the the one of 'ZSTR' have nothing in common. cstr/cstring would be fine for a new project but the BC break is terrible. Even for new functions/macros, I would keep str/string for C strings because consistency is the most important. Cheers François

« previous php.internals (#80832) next »