Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80129 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13785 invoked from network); 3 Jan 2015 23:42:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2015 23:42:48 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:41300] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/50-11248-67E78A45 for ; Sat, 03 Jan 2015 18:42:48 -0500 Received: by mail-wi0-f174.google.com with SMTP id h11so1302650wiw.1 for ; Sat, 03 Jan 2015 15:42:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=qCJ8VBT+h2vWqE/CDpfRwG9oexCtv/ofLLsQkRMHmn8=; b=cP7iL776vc7h9lW6pyx6/F4ZQlDPtXQOoIPQ8lEHjWVUAJ2oOtxf5m5iINHFyGtv1Q Im9NuB0Mogqd4FGyWSemomDV/8hoLRihy08uaOw1jEFL+nLBHrf49tHoozH2nUpnuM9u bUMlix5acmer8UH4rYmiFdTTQYTmWQKWzVQiZgjVjrXWjoPfNZLryKyOljJtjUXqO56Y GKvohtTvtYauO4rCDULdc+CQVLhdWSXw1mY+mg3VwpnRh/TWJtTBfxu+A1Yjgyj711c9 rkq8eZCQReblO1+h410RZW8iaj20Euxpfken2yb24a0RaSX/cnvXU7tf/iYlPnC96BLl dTdw== MIME-Version: 1.0 X-Received: by 10.180.76.201 with SMTP id m9mr11036483wiw.52.1420328564112; Sat, 03 Jan 2015 15:42:44 -0800 (PST) Received: by 10.27.10.196 with HTTP; Sat, 3 Jan 2015 15:42:44 -0800 (PST) Date: Sun, 4 Jan 2015 00:42:44 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=f46d043c08b687414d050bc80341 Subject: PHP 7 API naming conventions: str vs string From: nikita.ppv@gmail.com (Nikita Popov) --f46d043c08b687414d050bc80341 Content-Type: text/plain; charset=UTF-8 Hi internals! PHP 7 uses two different string types. One is the ordinary C string char*, the other is a custom zend_string* structure, which additionally embeds length and GC info. We currently have a bunch of APIs that accept either C strings or zend_strings, but the naming is pretty much random wrt str/string usage. Examples: * The main zend_string API is prefixed with zend_string_ * The smart string API for zend_strings uses the name smart_str, whereas the smart string API for C strings uses smart_string. To add insult to injury in PHP 5 smart_str was the one for C strings. * The hash API uses _str to denote APIs that accept C strings instead of zend_strings * ZVAL_STR is used for zend_strings, while ZVAL_STRING is for C strings * zend_str_tolower works on C strings, whereas zend_string_tolower is for zend_strings * ... many more Basically if you have two APIs, one using str, the other using string, you can't tell which one is for C strings and which one is for zend_strings. It could be either way. It would be nice to have a convention for this and stick with it. E.g. "string" is for zend_strings and "str" for C strings. Or maybe be more explicit and use "cstr" for C strings. (For symmetry the zend_string type could become zstr.) Thanks, Nikita --f46d043c08b687414d050bc80341--