Re: Initializing constants once, with code?
| From: | Robert Hickman | Date: | Fri, 10 Jan 2020 15:11:47 +0000 |
| Subject: | Re: Initializing constants once, with code? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108090@lists.php.net to get a copy of this message | ||
> > I stand by my comment that this has *some* of the same problems as a
> > separate "build" script, such as the need to be configured correctly,
>
> I find repeating of this as overstating the concern simply because any programming language
> feature would need to be used correctly. So this also feels like a distinction without a
> difference.
>
> > the difficulty of debugging errors in this special code,
>
> Depends? If this where to use XDEBUG just like regular PHP there would be zero difference.
>
> > and the need to invoke the extra processing manually for things like command-line scripts.
>
> Since PHP is different from a pre-compiled language like C or Go, it compiles
> "on-demand." So I would see zero need for a build step.
>
> I would also see PHP could first run the compile-time code once, and then run the runtime code
> for every execution. On-demand. And XDEBUG could be used for both.
>
> For CLI, it might always run the runtime code and then the compile time code. Unless there is a
> standard location set of compiled opcode in .ini file, and/or unless PHP provided ways to generate
> OpCode artifacts to be loaded at runtime.
>
> -Mike
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
There would be no definite build step in the sense of needing to run a
compiler, as this 'compile time code' would run once during preloading
on web code, and as sugested above, could be ran every time for
command line scripts, but cacheing the opcodes in a file and
automatically detecting changes and recompiling this as python does,
could be a worthwhile optimisation.