Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-15 Thread Robert Hickman
With regards to allowing AST introspection, john blow just posted a video on JAI which slows why it is useful. Around 11 mins into the following video he introduces a few lines into the metaprogram (the thing that interacts with the AST) which essentially 'queries' the code and reports all occurren

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-14 Thread Mike Schinkel
> On Jan 14, 2020, at 7:50 PM, Larry Garfield wrote: > I think you're still missing my point here. AST manipulation during preload > would exist to manipulate code that would be run *later*. That's the point. > Sure, the code in the run_once/preload/whatever block would be written to run > i

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-14 Thread Larry Garfield
On Tue, Jan 14, 2020, at 1:22 PM, Mike Schinkel wrote: > On Jan 14, 2020, at 1:10 PM, Larry Garfield wrote: > >> I get your concern about recursion, but if that kind of issue is really > >> a concern I don't see why we could not artificially limit recursion on > >> preload to a configurable amou

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-14 Thread Mike Schinkel
> On Jan 14, 2020, at 3:00 PM, kont...@beberlei.de wrote: > So like this old memoize extension? https://pecl.php.net/package/memoize Hmm. I am not familiar with it or how that works. Does it generate OpCodes with the literal return value, or simple cache the value? That said, my interest is in

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-14 Thread kontakt
Am 14.01.2020 um 20:23 schrieb Mike Schinkel : > > On Jan 14, 2020, at 1:10 PM, Larry Garfield wrote: >>> I get your concern about recursion, but if that kind of issue is really >>> a concern I don't see why we could not artificially limit recursion on >>> preload to a configurable amount, wit

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-14 Thread Mike Schinkel
On Jan 14, 2020, at 1:10 PM, Larry Garfield wrote: >> I get your concern about recursion, but if that kind of issue is really >> a concern I don't see why we could not artificially limit recursion on >> preload to a configurable amount, with 100 being the default? > > It's not recursion itself

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-14 Thread Larry Garfield
On Mon, Jan 13, 2020, at 1:26 PM, Mike Schinkel wrote: > Thanks so much for going into such detail. It really helped me > understand your concerns. > > I have been planned to propose an alternate to `static_run` because it > did not seem to me to be an ideal solution. And my proposal would no

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-13 Thread Robert Hickman
> > Hi folks, i think that we are getting a little confused here due to using the term 'preloading' for different things. As i have noted previously, my initial proposal of compile time execution would not depend on php's preloading feature, but could work, with opcache in the usual sense, or even

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-13 Thread Mike Schinkel
> On Jan 13, 2020, at 1:31 PM, Larry Garfield wrote: > > On Sun, Jan 12, 2020, at 6:45 PM, Mike Schinkel wrote: >>> On Jan 12, 2020, at 1:57 PM, Larry Garfield wrote: >>> >>> Most notably, *not all code will be run in a preload context*. >> >> Can you give some concrete examples here? >> >>

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-13 Thread Larry Garfield
On Sun, Jan 12, 2020, at 6:45 PM, Mike Schinkel wrote: > > On Jan 12, 2020, at 1:57 PM, Larry Garfield wrote: > > > > Most notably, *not all code will be run in a preload context*. > > Can you give some concrete examples here? > > > Language features that only sometimes work scare me greatly.

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-12 Thread Robert Hickman
I would say that my proposal is more about compile-time meta programming, and thus would not actually depend on preloading. It could also be ran during page requests and would be cached by opcache in the same way. However running it in that way could make the initial request before the opcodes are

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-12 Thread Mike Schinkel
> On Jan 12, 2020, at 1:57 PM, Larry Garfield wrote: > > Most notably, *not all code will be run in a preload context*. Can you give some concrete examples here? > Language features that only sometimes work scare me greatly. Do you have some examples of language features, from PHP or anot

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-12 Thread Robert Hickman
> Once you are in a live environment you want a read-only file system, for > security and auditability. Code generation at that point is then impossible. > Moving that code gen to a preloader wouldn't help with that. My proposal has no impact on the file system. It would modify the AST, and th

Re: [PHP-DEV] Introducing compile time code execution to PHP preloading

2020-01-12 Thread Larry Garfield
On Sat, Jan 11, 2020, at 6:40 AM, Robert Hickman wrote: > With PHP having recently introduced preloading, i have been thinking > about the possibility of adding a system whereby arbitrary php code > can run during this step. Essentially, this would serve the same > function as 'compile time executi