Python Quiz

Mark Jackson mjackson at alumni.caltech.edu
Wed Jul 16 11:37:58 EDT 2003


Peter Hansen <peter at engcorp.com> writes:
> Mark Jackson wrote:
> > 
> > Michael Chermside <mcherm at mcherm.com> writes:
> > > Of course, I'm not suggesting that whitespace is *meaningless* in Python
> > > outside of indentation... Python is much like C (and many, many others) in
> > > that regard. 
> > 
> > Note that Fortran (at least historic Fortran - not sure about those
> > upstart 9x variants) is *not* among the "many, many others."  One can
> > write any of
> > 
> >         DO 10 I = something
> >         DO10I = something
> >         D O 1 0 I = something
> > 
> > and leave it to the compiler to figure out whether you're starting a
> > DO-loop or assigning a value to the variable DO10I.
> 
> If you are saying that you leave it up to the compiler to decide how
> to interpret any of the three above statements, then clearly whitespace
> is *not* meaningless.  It might be compiler-dependent or something,
> but no meaningless.  Unless you are saying that on a given FORTRAN
> compiler, only one possible interpretation of all three statements
> above is possible.  That would be surprising.

You misunderstand, probably because I didn't express myself clearly.
Again from the Sun Fortran Reference Manual, "Special characters used
for punctuation," after the graphic used in the manual for the space
character:  "Ignored in statements, except as part of a character
constant."

Ignored means *ignored*, the three examples given will be parsed
identically and the meaning will be determined using other
information.  I think in this case the nature of "something" should be
determinative, as the syntax for the range and stride of a DO-loop

	start, stop [,stride]

doesn't match any legal expression (which is what would be required if
this were assignment to the variable DO10I.

But it's perfectly legal, if insane, to declare (or, with implicit
typing undefeated, just go ahead and use) a variable named DO10I and
write, say

	DO 10 I = 1.10

because in Fortran whitespace is *not* considered to delimit tokens.

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
	It is necessary to be slightly underemployed if you want to
	do something significant.	- James D. Watson






More information about the Python-list mailing list