Re: Initializing constants once, with code?
| From: | Robert Hickman | Date: | Wed, 08 Jan 2020 16:10:21 +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 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108039@lists.php.net to get a copy of this message | ||
> After posting my objection to pre-processing I remembered there was another reason I object to
> pre-processors that is even more significant than lack of composibility. And my objection extends
> to all the transpiring being done with Javascript and CSS too, although I put up with those because
> the community has mitigated some of the worst problems and because so many developers have embraced
> them.
>
My suggestion was not a preprocessor, but what others have said
already, a 'shim' that goes between the parser/lexer and bytecode
generation which allows user code to inspect and modify the AST. This
idea is not unusual and Python for example can do this. The idea is
the basis of macro systems in Lisps, and Rust has a very nice
implementation of it from what I've seen in passing. The system should
be fully aware of the syntax, scoping, namespaces etc, the lack of
which is the problem with C preprocessor for example.
With regards to how JAI does this:
https://www.youtube.com/watch?v=UTqZNujQOlA
https://www.youtube.com/watch?v=59lKAlb6cRg&list=PLmV5I2fxaiCKfxMBrNsU1kgKJXD3PkyxO&index=20&t=0s