Whitespace delimiters suck

Thomas Wouters thomas at xs4all.net
Fri Jan 21 06:48:35 EST 2000


On Thu, Jan 20, 2000 at 05:04:34PM -0800, tye4 wrote:
> Whitespace end delimiters are invisible and hence confusing and prone to
> error. I've used some stupid Unix shell languages which fail if I add
> whitespace:

> I thought they gotten rid of all such languages until I came across Python.
> Good programming languages should be whitespace tolerant, and most of them
> are.
> (C++, Java, Ada, BASIC, HTML, Eiffel, Perl, Pascal, ML etc... really long
> list.)

Yeah, right. You dont honestly believe all of those languages are
white-space tolerant ? In C (or C++), what does this mean:

y+++x;

Is that y++ + x, or y + ++x ? If you add whitespace, the compiler will do
something different. Worse, this is invalid:

y+++++x;

Eventhough there IS only one possiblity, whitespace is NEEDED to make the
distinction. If you do not use whitespace, the compiler will think you mean
'y++ ++ +x' and will complain. The same goes for other languages with
autoincrement/decrement, by the way.

> Why is my question about whitespace raise so many eyebrows? This feature is
> commonplace.

Whitespace is a GOOD thing. it makes things readable. You aren't, however,
objecting to the use of whitespace, you're objecting to the use of
indentation. No, wait, not even that, you're objecting to the lack of
end-block markers, which you would use _in addition_ to indentation. Well,
you can do that, using the 2nd neatest invention of Guido's, called
'comments'. They're so cool, every language implemented them right away,
sometimes even using Guido's time machine to correct the oversight years
ago !

This whole discussion and your plan to add end-block markers reminds me of
how the bourne shell (the original one) was written. In C, but with a bunch
of macros to make the language look more like another language (Pascal, i
think.)

#define IF if (
#define THEN ) {
#define ELSE } else {
#define ENDIF }

and similar ones for while/do-while, for, switch, etc. Apparently, it was a
lot easier for Steve Bourne to program in, because he was used to these
constructs, but it made maintaining the original bourne shell a living
nightmare for everyone who was not used to these constructs (and, i imagine,
for Steve himself aswell, after he got used to C and forgot about Pascal :)

Steve probably didn't have much choice, he had to program the bourne shell
in C. But you DO have a choice. There are so many programming languages
about, nowadays, and a lot that you are free to download, install and use in
any environment. Dont like the indentation as block delimiters ? It's one of
the core features of Python, and it reflects quite accurately Python's
philosophy. I'd venture to guess you wont get the same satisfaction out of
Pythons (to us) obvious features, and it's great intuitivity. Perhaps you
can find everything you need in some other language. I doubt molding and
mauling the language into something you do like, making it incompatible with
the 'core' python, will get you that satisfaction.

(auto-increment and bourne-shell examples blatantly stolen from Peter v/d
Lindens' excellent "Deep C Secrets", by the way, which my SO misplaced
again, which is why i'm not clear in the details of the last story ;P
Frustrating how she always misplaces my favorite books.)

			-ly y'rs,

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list