Python Newbie

Chris Angelico rosuav at gmail.com
Mon Feb 25 02:27:51 CET 2013


On Mon, Feb 25, 2013 at 12:04 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Not at all. The only difference is whether you get a compiler error or a
> runtime error. Instead of:
>
> 10 Write code.
> 20 Compile.
> 30 If compiler error, GO TO 10.
> 40 REM code compiles, but it still needs to be tested
> 50 Test code.
> 60 If error, GO TO 10.
> 70 Deploy.
>
> we have:
>
> 10 Write code.
> 20 Test code.
> 30 If error, GO TO 10.
> 40 Deploy.

The advantage of compile-time errors is that you don't have to wait
for *that branch* to be executed. So they're hugely advantageous when
it comes to the "obvious problems" like syntactic errors... and looky
here, Python does exactly that :) The only difference between "static"
and "dynamic" is how much is done at each phase.

If your program has no inputs or side effects, the compiler could
theoretically convert it into a single static output statement. Voila!
All your run-time errors have become compile-time errors. Conversely,
you could compile your application from source just before running it.
Voila! Everything's a run-time error, even the omission of a semicolon
in C. Okay, both of those are pretty stupid examples, but there's
really no fundamental difference.

ChrisA



More information about the Python-list mailing list