Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97675 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71273 invoked from network); 11 Jan 2017 13:36:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jan 2017 13:36:29 -0000 Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.68 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.215.68 mail-lf0-f68.google.com Received: from [209.85.215.68] ([209.85.215.68:36211] helo=mail-lf0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/DC-55699-CD436785 for ; Wed, 11 Jan 2017 08:36:28 -0500 Received: by mail-lf0-f68.google.com with SMTP id h65so920649lfi.3 for ; Wed, 11 Jan 2017 05:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:subject:references:date:mime-version:content-transfer-encoding :from:message-id:in-reply-to:user-agent; bh=QwaV8Y5iVkjwzgF5IstTNjNbWHCMwuGgRnk3gY1Yank=; b=lf/zyn3TGOctI1AwLjqHc8DruahPCgi06KtNRRY9l3HBpBy3d9eux1x+2nLlrHaiYN tQtJKe+7fZKzoKOhtb6/x/ZWUMM2oI0fX76tU4yehYKWgq+ItyLiIPA02sa95SC2ExNS AsUpPqu4+CFymYhQ845/JLnkRUE3Vb1M3bGCPm3sai+lLqFlc0jxIJe00xPHn62hNMS1 y3vaYP4KZoyQJKX4+PGHG+yEClwRqW8Z0PnnehwVtQIVtGpOAMcUCNOHCHYozxTwUrF7 NXuncJjp6iZr5eY0qBpvdFGghgg7XzfEwVAtmFtfHW29rZP/Qub0bp/BA07upjl9ExaE Mmag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=QwaV8Y5iVkjwzgF5IstTNjNbWHCMwuGgRnk3gY1Yank=; b=qk7F+xX9z0SG7CEQ8EJeXRCl9QEOglrmBAoeBEe0j1fw4xZu7sEtbUV9M9HiC/M1Sv 85iaBdMRv3mBZvVUhqERmpV4G0zVFkXfmMnL4//7cOtK9Rsis9UKqR8LroKE6lmkjkj0 1UaRWSFaNO5StMapDoeKAoeqDSm31t5qh/H8y4s1CYS+jgGUih7xFn76uXDEDMCmV16a 74tWplPfWko+ScG1UGm/42BnluOFCck4sL3jgQ5JblgzN+ip3+1sviC8s/0wOlTgTuYs GZRPLc0cJQeIBbfiJi3F10hg/gJloVzDz3mFdizsBlvHTOHZyPy+30qc9SRGeWKtFyQF Vjtg== X-Gm-Message-State: AIkVDXKyUyVLr0TSbSXg2fJ6FeQziN4kuYPPB3YOvkpPeRVkgEQgAUMExv866iUoToShpw== X-Received: by 10.46.7.1 with SMTP id 1mr3474120ljh.76.1484141784918; Wed, 11 Jan 2017 05:36:24 -0800 (PST) Received: from nikita-work-box ([185.62.192.230]) by smtp.gmail.com with ESMTPSA id s64sm1338991lfs.38.2017.01.11.05.36.23 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 Jan 2017 05:36:24 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "PHP internals list" , "Dmitry Stogov" References: Date: Wed, 11 Jan 2017 16:35:52 +0300 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: User-Agent: Opera Mail/12.16 (Linux) Subject: Re: [PHP-DEV] Change in type-hint representation From: inefedor@gmail.com ("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 > just 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 [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.