Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97687 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89613 invoked from network); 11 Jan 2017 14:33:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jan 2017 14:33:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 104.47.32.129 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 104.47.32.129 mail-sn1nam01on0129.outbound.protection.outlook.com Received: from [104.47.32.129] ([104.47.32.129:10304] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/D0-55699-A1246785 for ; Wed, 11 Jan 2017 09:32:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Qs2mjQGahMqu5b0tsGAfQqHhcctZ8lVgbNjgYDhoNcc=; b=FIHQIP4TUQiJuKu6oZ3nV0JJLENmDKNmn5AIcJ7aZ/Q+e2F3HK/BN/ZMRLj419h3Ov2S1pEgYCC28gLxhxEfZ4UqxKN7yvoFgnjima25JxC21AdGfIaagJ9ltK9PVo40gZXYBeEJORWV2T7eZFrzjbLxRYkYOCp7F9vIQREJogY= Received: from MWHPR02MB2477.namprd02.prod.outlook.com (10.168.204.147) by MWHPR02MB2479.namprd02.prod.outlook.com (10.168.204.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.829.7; Wed, 11 Jan 2017 14:32:55 +0000 Received: from MWHPR02MB2477.namprd02.prod.outlook.com ([10.168.204.147]) by MWHPR02MB2477.namprd02.prod.outlook.com ([10.168.204.147]) with mapi id 15.01.0829.017; Wed, 11 Jan 2017 14:32:55 +0000 To: =?iso-8859-2?Q?Micha=B3_Brzuchalski?= CC: Dmitry Stogov , PHP internals list , Nikita Nefedov Thread-Topic: [PHP-DEV] Change in type-hint representation Thread-Index: AQHSbBcuJH94e0ZZMkmDI5OUmOzW+w== Date: Wed, 11 Jan 2017 14:32:54 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmitry@zend.com; x-originating-ip: [213.21.45.232] x-microsoft-exchange-diagnostics: 1;MWHPR02MB2479;7:dny1h0Jiae3qMDUaE6W5zYyP9B0Y4nq6YrtXcPfQ3l6DgohL45wwe/wOmodsUMJ7SOxFMqe3CE0JMv66GrfM1EyJjfVvJk5haY9B9Sa4Fn9TIMdJ/qYw4nuo9UMB4Ob3+eRHtrpcynPFFgaJWyM1caQS0QcMH1fJ8sbLODWStYVExvT0/YuxF72Dv0J7Ppbde7zjRjzbCSmpLoVYYfODH7wdqrcHeJnTeRm6aE0Yora7Qq+AeHnsjzyTwUn7ONwxONrnqJZnAg86RN7aHk8qS7ZcTN37iYU3EvQhgOo5shdjbi/gC3sMmtRCv7RVPbk+wGxSUdQOT/UmVru3bqwRSbtTFJ0b5pM3od5DSHzTAiajKwUh/bvLXU+RrdF9VdqWHnuHEO+cTpSj0IzleUk31HHijI5WZjvpZl+DJniVXQRmrEGnTxik+jYAb7vCPsuv0YJNAYiHrRMaJ2wXomjDFA== x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10019020)(7916002)(39450400003)(377424004)(189002)(377454003)(199003)(24454002)(86362001)(5660300001)(4326007)(54896002)(6306002)(189998001)(7696004)(77096006)(3280700002)(39060400001)(110136003)(38730400001)(2906002)(66066001)(6916009)(9686003)(236005)(33656002)(606005)(54356999)(50986999)(3660700001)(97736004)(8936002)(575784001)(8676002)(15198665003)(106116001)(305945005)(81166006)(7736002)(81156014)(7906003)(74316002)(102836003)(106356001)(105586002)(6116002)(3846002)(16297215004)(229853002)(2900100001)(25786008)(15395725005)(101416001)(92566002)(6506006)(122556002)(68736007)(6436002)(54906002)(99286003)(55016002)(15188155005)(16799955002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR02MB2479;H:MWHPR02MB2477.namprd02.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 75da2c00-5736-42be-15e8-08d43a2ebb3d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR02MB2479; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(23657631684272)(166708455590820)(192278398808882)(185789414550570); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148);SRVR:MWHPR02MB2479;BCL:0;PCL:0;RULEID:;SRVR:MWHPR02MB2479; x-forefront-prvs: 01842C458A received-spf: None (protection.outlook.com: zend.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_MWHPR02MB2477D2804A1F04F6D37E5E36BF660MWHPR02MB2477namp_" MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2017 14:32:54.7709 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2479 Subject: Re: [PHP-DEV] Change in type-hint representation From: dmitry@zend.com (Dmitry Stogov) --_000_MWHPR02MB2477D2804A1F04F6D37E5E36BF660MWHPR02MB2477namp_ Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable On Jan 11, 2017 4:51 PM, Micha=B3 Brzuchalski wrot= e: 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 just a= n adoption for new type representation. I don't think we need RFC, because this is just an internal change that doe= sn'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-typeh= int where IS_OBJECT is used without class name as type hint for any object kind, if t= his 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 w= ould give me empty zend_string value right? So that won't bive me any chances to store I= S_OBJECT without classname am I right? It should be still possible to use IS_OBJECT without class name. ZEND_TYPE_ENCODE_HINT(IS_OBJECT, 0) this even should start working out of the box. Thanks. Dmitry. [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 -- regards / pozdrawiam, -- Micha=B3 Brzuchalski about.me/brzuchal brzuchalski.com --_000_MWHPR02MB2477D2804A1F04F6D37E5E36BF660MWHPR02MB2477namp_--