News for hackers. Stuff that matters.
Re:What Makes the Zig Programming Language Unique? by dolmen on Thursday October 06, 2022 @09:14AM (#33107794)
Perl 5 had compile-time execution forever. And this feature is used in everyday's code as that feature is at the core of the implementation of exporting symbols from a module into its importer (See module Exporter).

Example: the BEGIN block is executed during the compile phase as the parser encounters it. The code injected in BEGIN blocks can affect how the rest of the file is parsed.

    $ perl -E 'exit; BEGIN { say "Hello" }'
    Hello
"perl -c" stops the program after compile, but before execution. In the following code the BEGIN block runs, but not "exit 1".

    $ perl -c -E 'exit 1; BEGIN { say "Hello" }'; echo $?
    Hello
    -e syntax OK
    0
More info:

* https://perldoc.perl.org/perlmod#BEGIN,-UNITCHECK,-CHECK,-IN...

* https://perldoc.perl.org/perlfunc#use-Module-VERSION-LIST

There are no comments on this comment yet.