Necessity of ``pass''

Stephan Houben stephan at pcrm.win.tue.nl
Tue Aug 24 09:16:56 CEST 1999


forcer <forcer at mindless.com> writes:

> Hi there.
> 
> Lately, i've been thinking about Python. While it is an
> exceptionally clean language, it has one very obvious wart:
> The ``pass'' statement.
> 
> To quote the reference manual:
> 
>    pass is a null operation -- when it is executed, nothing
>    happens. It is useful as a placeholder when a statement is
>    required syntactically, but no code needs to be executed, for
>    example:
> 
>    def f(arg): pass    # a function that does nothing (yet)
> 
> So it happens that Python has places where semantically nothing
> should be done, while syntactically it requires a statement.

I don't agree. It is very important for a programming language
to have a "do nothing"-statement, if only to satisfy the
computer scientists among us. The first program (well, actually
Hoare-triple) we had to prove in first-year CS was:

{P} skip {P}

,were skip was the "do nothing"-statement in the Guarded Command
Language. It's essential to have such a statement, because
it behaves as the identity of the "composition" operator on
the statements in your language, i.e. you have that

pass; X

is equivalent to just

X

for every statement X. This is also true in Python.

Greetings,

Stephan




More information about the Python-list mailing list