Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83373 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63892 invoked from network); 21 Feb 2015 02:03:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Feb 2015 02:03:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:57954] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/43-45394-987E7E45 for ; Fri, 20 Feb 2015 21:03:54 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id D8DC64B0117; Sat, 21 Feb 2015 03:03:46 +0100 (CET) Reply-To: To: "'Dennis Birkholz'" , References: <54E7822F.4070307@fischer.name> <54E7882B.30800@birkholz.biz> <057201d04d50$be289f00$3a79dd00$@php.net> <54E7A56E.2030005@birkholz.biz> In-Reply-To: <54E7A56E.2030005@birkholz.biz> Date: Sat, 21 Feb 2015 03:03:47 +0100 Message-ID: <059801d04d7a$a0e9cc50$e2bd64f0$@php.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQIyuUwUVFIdYJq88tPJ7BNGL6d/pQFphJKyAV6NKKICWzu9jQGZbCefm/+QOxA= Content-Language: fr X-Antivirus: avast! (VPS 150220-1, 20/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] [RFC] Reserve EVEN MORE types for PHP7 From: francois@php.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) Hi Dennis, I didn't consider defining builtin type hints as classes because : - I think it would be slower, and we need speed, but I agree, I did no = test - no pre-defined namespace exists to handle this - Reverting to the root namespace makes it twice slower. The case of = functions is nothing more than a hack to have a flawed design approved = by all means. - Storing builtin types in the root namespace would cause exactly the = same problem of sharing a naming space with user-defined names. - and probably the most important one: the implementation is based upon = the ZPP layer, which allows internal and userland type hinting to follow = exactly the same logic. About namespaces : no type hinting feature is currently planned at the = namespace level, except the usual class resolution when a class name is = used as hint. Some may exist in the future as there will probably be = more links between built-in types and classes, such as specializing and = combining builtin types using a userland class or exposing builtin-types = as classes. Regards Fran=C3=A7ois > -----Message d'origine----- > De : Dennis Birkholz [mailto:dennis@birkholz.biz] > Envoy=C3=A9 : vendredi 20 f=C3=A9vrier 2015 22:22 > =C3=80 : internals@lists.php.net > Objet : Re: [PHP-DEV] [RFC] Reserve EVEN MORE types for PHP7 >=20 > Hello >=20 > Am 20.02.2015 um 22:03 schrieb Fran=C3=A7ois Laupretre: > >> I just wonder why we need to prohibit these names. Can types not = reside > >> in the global \ namespace? We could then change the class = resolution > >> rules to allow to look also in \ as is done for functions = currently. > >> > >> Thanks > >> Dennis > > > > This is not a question of namespace resolution. Built-in type hints = and > namespaces have nothing in common. >=20 > I do not know how the actual implementation works, but I assume there = is > a symbol table for each namespace that contains a list of > class/trait/interface names for that namespace. Why not enhance this > mechanism to contain all type information for each namespace? Simple > types go into that symbol table, type aliases, type defs/enum types = (if > such a thing gets implemented), union types, etc. In addition, if the > current namespace symbol table does not contain an entry (and the > autoloader fails), the root namespace is tested for a name. >=20 > > It is just about the logic of : > > > > Class resource { > > ... > > } > > > > Function foo(resource $arg, ...) > > > > Do we check $arg to be I_RESOURCE or an instance of the 'resource' = class ? >=20 > The class definition would give an error, as "resource" already exists > in the topmost namespace. >=20 > namespace test { > Class resource { ... } > function foo(resource $arg, ...) > } >=20 > function bar(resource $arg, ...) >=20 > foo uses the class test\resource, bar uses the resource type from the > root namespace. >=20 > Maybe PHP works completely different internally and this is not > feasible. But reserving some names from being valid as a class name > sounds like a hack, I would prefer a clean and generic solution. >=20 > Thanks > Dennis >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php