[Python-Dev] Terminology for PEP 343

Raymond Hettinger python at rcn.com
Mon Jul 4 05:10:33 CEST 2005


I'm referring to the specific meaning of "guard" in a computer science
context:

     http://www.computer-dictionary-online.org/guard.htm?q=guard

>From David Gries, The Science of Programming, if statement contains two
entities of the form B --> S wehere B is a Boolean expression and S a
command.  B --> S is called a guarded command.

I believe that terminology is rooted in Dijkstra's language of guarded
commands (used to express and facilitate program proofs).  They are
essentially the same as conditionally executed statements but may be
executed non-deterministically:

    http://cs-exhibitions.uni-klu.ac.at/contentGuardedCommand.php

Also, I believe the pattern matching part of Prolog clauses are called
guards; however, the conditional execution is deterministic (the first
match is the one that fires) and potentially recursive.

This terminology is used consistently among various functional
programming languages.  From,
http://www.cs.ecu.edu/~karl/astarte/glossary.html , "A guard in a case
is the condition that is being tested. For example, in case a => b,
expression a is the guard."

In predicate calculus, the phrase, "strengthening the guard" has a
specific meaning with the "guard" part being consistent with the above.
One example:

   http://www.cs.utexas.edu/users/psp/unity/notes/07-89.pdf

IOW, guard is a specific term, not an amorphous metaphor that can be
accurately applied to the enter/exit or enter/leave pair.


Raymond





> -----Original Message-----
> From: Michael Walter [mailto:michael.walter at gmail.com]
> Sent: Sunday, July 03, 2005 10:28 PM
> To: Raymond Hettinger
> Cc: rrr at ronadam.com; python-dev at python.org
> Subject: Re: [Python-Dev] Terminology for PEP 343
> 
> Hmm, I think I'm seeing mostly the (guarded) entry/exit part of
> "guard" metaphor, but I see what you mean (not allowing "entry", so to
> say, right?). Not sure.
> 
> Michael
> 
> On 7/3/05, Raymond Hettinger <python at rcn.com> wrote:
> > >   "Guarding a scope with a decimal.Context() object <explain
effect>."
> >
> > Doesn't "guard" suggestion conditional execution?
> >
> >
> > Raymond
> >


More information about the Python-Dev mailing list