"no variable or argument declarations are necessary."

Ron Adam rrr at ronadam.com
Mon Oct 3 16:11:08 EDT 2005


Steven D'Aprano wrote:
> On Mon, 03 Oct 2005 06:59:04 +0000, Antoon Pardon wrote:

> 
> x = 12.0 # feet
> # three pages of code
> y = 15.0 # metres
> # three more pages of code
> distance = x + y
> if distance < 27:
>     fire_retro_rockets()
> 
> And lo, one multi-billion dollar Mars lander starts braking either too
> early or too late. Result: a new crater on Mars, named after the NASA
> employee who thought the compiler would catch errors.

Yes, and a reserved position in the unemployment line as well, I would bet.

> Declared variables have considerable labour costs, and only marginal
> gains. Since the steps you take to protect against other errors will also
> protect against mistyping variables, declarations of variables is of
> little practical benefit.

Also checking types is not the same as checking values.

In most cases where critical code is used you really want value testing 
not type checking.  This is where self validating objects are useful and 
there is nothing preventing anyone from using them in Python.

Cheers,
Ron



More information about the Python-list mailing list