3 ms·
It's not the same thing. In Python this is a run-time error. The code you posted is parsed and compiled to byte-code just fine. Then, depending on the time, a n
by ceronman 11y ago
It's not the same thing. In Python this is a run-time error. The code you posted is parsed and compiled to byte-code just fine. Then, depending on the time, a new function is created dynamically at run-time or a NameError is raised at run-time.
In Python and other dynamic languages the compilation part is very simple, the code is parsed (the grammar is very simple) and converted to byte-code. Then the byte-code is executed. Things like function and class definitions happen at run-time, not at compile-time.
In Perl 5, the line between compilation-time and run-time is very fuzzy. It doesn't have a simple grammar that you can use to convert Perl to op-code. You can run code at compilation-time and change the way the compiler interprets things.