Re: PHP header files, restrict to declaring code only
| From: | Johannes Schlüter | Date: | Mon, 13 May 2019 12:48:57 +0000 |
| Subject: | Re: PHP header files, restrict to declaring code only | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105685@lists.php.net to get a copy of this message | ||
On Fr, 2019-05-10 at 15:14 +0200, Lynn wrote:
> Hi Nikita,
>
> By limiting a header file to declaring code only, a couple of issues
> could
> be tackled:
>
> 1. No side effects when loading files. You can assume the global
> state
> remains the same, no
> code is executed by this file, and no output can be sent.
Mind that this won't be side-effect free. Declaring a class/function is
a side-effect in itself.
For dealing with syntax differences we could use the declare()
statement, as used for strict_types or encoding.
A question is whether it is worthwhile to have multiple syntaxes in
parallel. This adds burden for developers using PHP, (i.e. copying code
from tutorials or other files might fail sometimes etc.) tools
processing PHP (IDEs, code analyzers, ...) and language developers (new
syntax changes have to be evaluated for both contexts)
If this were a strategy to transition to a new syntax (deprecating "old
PHP") such a mechanism would be the way to go. For just having
alternatives to avoid a syntax conflict cost imo is too big.
johannes