Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85988 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39033 invoked from network); 28 Apr 2015 12:09:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2015 12:09:32 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.171 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.171 mail-wi0-f171.google.com Received: from [209.85.212.171] ([209.85.212.171:35418] helo=mail-wi0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/04-17556-B787F355 for ; Tue, 28 Apr 2015 08:09:31 -0400 Received: by widdi4 with SMTP id di4so137389205wid.0 for ; Tue, 28 Apr 2015 05:09:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=s2YNnNFg4yh+yPreMBJZtLhXxuHFQ7vhqltltaxrM7E=; b=Lt65A5qjFxtWPf4BzEuNbREpokWaEu8cCzuHrZazbQDaqp+pvPzq5Fwr6iEu2liMZu 18W0Dr3awO7wUlfXtDV7gMdZXBWvwM/fZ50nFYElfmUXYSDuWmRO0pT5Jfy+hQA4DqjB 3DGBYouGY/Wzgqf/wKCUjxD9hXd3MeryC5bKAFkRSegpOtSTf6y1UEfW4y20X6+U20hJ nbYZyyRQIQgluJCvt5SUFM1x0UsA8PRDZo+cGdMafBFZf7LFf4/BsQzYLE41LBrILMSy 0/qvSwqUGgMFcxDpV8jkDIOqBZ+Dc2QRS6oSpxXaXk08ezu+99yP1panOKVMzzoypeBl Ipow== X-Received: by 10.180.216.40 with SMTP id on8mr26251033wic.55.1430222968381; Tue, 28 Apr 2015 05:09:28 -0700 (PDT) Received: from [192.168.0.159] ([62.189.198.114]) by mx.google.com with ESMTPSA id k2sm16126598wif.3.2015.04.28.05.09.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Apr 2015 05:09:27 -0700 (PDT) Message-ID: <553F7818.1040402@gmail.com> Date: Tue, 28 Apr 2015 13:07:52 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: internals@lists.php.net References: <553DBEC4.7000609@gmail.com> <006c01d081a7$0e600640$2b2012c0$@php.net> In-Reply-To: <006c01d081a7$0e600640$2b2012c0$@php.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Re: [RFC] Reserving More Types in PHP 7 From: rowan.collins@gmail.com (Rowan Collins) François Laupretre wrote on 28/04/2015 12:32: > Bare class names are still recognized and priority is given to class names (if a 'String' class is defined, every 'String' or even 'string' type hints will always refer to it). This part is likely to be rather tricky to implement. How do you know if a 'String' class is defined or not? The Engine would have to do something like this: - check in-scope use statements for resolutions of 'String' to a qualified name - if in namespace scope, try class_exists(__NAMESPACE__ '\String'), invoking autoloader if registered - if not in namespace scope, check class_exists('String'), invoking autoloader if registered - if class found, hint is an object instanceOf check - else, hint is a scalar check All of this (apart from resolving use statements) has to run *every time the hint is processed*, since there is no limit on when a class can become defined. The user has no way of avoiding this penalty, even if they never intend to declare a String class. In contrast, reserving the hint "string" allows the *compiler* to immediately choose a scalar check, and an instanceOf check never needs to run an autoloader, because if the class isn't declared, there can't possibly be an instance of it. Regards, -- Rowan Collins [IMSoP]