Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106568 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12210 invoked from network); 13 Aug 2019 20:16:46 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 13 Aug 2019 20:16:46 -0000 To: internals@lists.php.net References: <25d774e8-183b-d39c-4ac4-81c1b7770229@gmail.com> <5d5298a5.1c69fb81.b4ed1.2d97SMTPIN_ADDED_MISSING@mx.google.com> <3db68c5e-54d1-812f-bbf5-1b089cba1bff@gmail.com> Date: Tue, 13 Aug 2019 18:45:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <3db68c5e-54d1-812f-bbf5-1b089cba1bff@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Posted-By: 94.4.34.143 Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares, again From: markyr@gmail.com (Mark Randall) Message-ID: On 13/08/2019 18:05, Rowan Collins wrote: > This seems to be more complicated than Nicolas's version, and involve > much more special magic, like the name __nsmeta, and the class that does > nothing. I'm also not clear on how you're picturing the relationship > between namespaces and packages. I was looking for a way that would be intuitive to the existing system. We already have an existing userland system for locating a class. By using a placeholder class we can locate it using our existing logic. > class project1 extends \PHP\Package { >     public function getParserDirectives() { >         return [ >             'strict_types' => 1, >             'strict_operators' => 1, >             'upgrade_errors_to_exceptions' => E_ALL >         ]; >      } > } I thought about this as my first consideration, however it effectively requires that the PHP code within the package class is fully parsed and executed in order for it to retrieve the data. Consider pre-loading where the code is compiled, but not run, it would not be possible to use namespace level defines to add compile-level optimizations or checks (at least without some AST hackery). Meanwhile, the compiler itself could pull out a namespace_declare block and fully understand the information in it without actually needing to run anything. If I was writing a runtime package system, I would absolutely do it in the way you suggest, and in fact I already do for my own packages which deal with wrapping up css / js / html template files. Perfect for runtime, not so good for compile time, but if I'm wrong I dare say someone will let me know. Mark Randall