Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74438 invoked from network); 11 Jan 2017 13:51:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jan 2017 13:51:55 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:52699] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/7D-55699-87836785 for ; Wed, 11 Jan 2017 08:51:54 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 362B52984233 for ; Wed, 11 Jan 2017 14:51:50 +0100 (CET) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id k8mZmxliCBsM for ; Wed, 11 Jan 2017 14:51:48 +0100 (CET) Received: from mail-ua0-f180.google.com (unknown [209.85.217.180]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 5B74F2984235 for ; Wed, 11 Jan 2017 14:51:23 +0100 (CET) Received: by mail-ua0-f180.google.com with SMTP id 35so76769584uak.1 for ; Wed, 11 Jan 2017 05:51:23 -0800 (PST) X-Gm-Message-State: AIkVDXLC4xcjShLbNQKCth3WMy0+Et3uVydeofusvlvXusWIiIztVosU2pM7bpOm8m7s0b60uO2+swx/7/HFqg== X-Received: by 10.176.17.18 with SMTP id e18mr4251595uab.112.1484142682869; Wed, 11 Jan 2017 05:51:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.35.204 with HTTP; Wed, 11 Jan 2017 05:51:22 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Jan 2017 14:51:22 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Nikita Nefedov Cc: PHP internals list , Dmitry Stogov Content-Type: multipart/alternative; boundary=f403045e3b6e689c330545d1e54a Subject: Re: [PHP-DEV] Change in type-hint representation From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --f403045e3b6e689c330545d1e54a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2017-01-11 14:35 GMT+01:00 Nikita Nefedov : > On Wed, 11 Jan 2017 15:07:39 +0300, Dmitry Stogov wrote= : > > Hi, >> >> >> I propose to introduce a unified type representation (zend_type). >> >> Now it's going to be used for typing of arguments and return values. >> >> Later we should use it for properties and other things. >> >> >> https://gist.github.com/dstogov/1b25079856afccf0d69f77d499cb0ab1 >> >> >> The main changes are in zend_types.h and zend_compile.h, the rest is jus= t >> an adoption for new type representation. >> >> I don't think we need RFC, because this is just an internal change that >> doesn't change behavior. >> >> >> I got the idea working on typed properties together with Bob and Joe. >> >> https://github.com/php/php-src/compare/master...bwoebi:typed >> _ref_properties >> >> I think it would be better to introduce zend_type and then continue work >> on typed properties. >> >> >> Any comments? >> >> >> Thanks. Dmitry. >> >> >> > Hey Dmitry, > > Having worked on callable prototypes I'd say unifying PHP types in Zend > is something we urgently need for PHP to continue evolving. > > I'm not sure if PHP have ever been compatible with less-than-32bit > archs but if it was I think it should be said that this would break > such compatibility though. > > It would be great if there were some comment in the code near zend_type > declaration where you'd explain how it is used and how additional > data is being added to the pointer. > > Is there any use of ZEND_TYPE_CE() macro? It seems to be forgotten there? > > If I understood this correctly, the layout of zend_type is as follows: > > [xxxx xxxx xxxx xxxx] xxxx xxxx xxxx xxy0 - for IS_OBJECT type hint > where the `xxxx`s are a (zend_string *) pointer and `y` designates > an allow_null flag > > I've got prepared Object Typehint RFC https://wiki.php.net/rfc/object-typehint where IS_OBJECT is used without class name as type hint for any object kind, if this patch would be applied how can I deal with this new zend_type? As far as I undestand last 0 for IS_OBJECT and no (zend_string *) pointer would give me empty zend_string value right? So that won't bive me any chances to store IS_OBJECT without classname am I right? > [xxxx xxxx xxxx xxxx] xxxx xxxx xxxx xxy1 - for all other type hints > where the `xxxx`s are a IS_CALLABLE, _IS_BOOL, IS_LONG, IS_DOUBLE, > IS_STRING or IS_ARRAY > > Do we decide here that IS_REF modifier should belong to the concrete > usages of the type (e.g. referentiality is a property of a variable > and not of a type)? > I'm not sure this if is a right decision or not but I feel like this > question should be raised. It is usually the opposite in other languages. > > How would you plan to extend this further? Let's say at some point we > will have callable prototypes or generic classes: we will need to encode > somehow this type into zend_type: `callable(A)` or `A`. > Even right now it might be useful (as you suggest with ZEND_TYPE_CE) > to store a (zend_class_entry *) instead of (zend_string *) when > it is known to us in the zend_type. > Seems like without extending zend_type to the size of two pointers > it almost isn't doable :\ > Or, it could be made that zend_type, when it's not a simple type hint, > would point to the `zend_type_complex` which would store a > zend_class_entry pointer (or not, if it's for callable) and an array > of type specifiers. But that introduces another indirection. > > Anyway thanks for polishing this part, we definitely need zend_type in > some form. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --f403045e3b6e689c330545d1e54a--