Re: New Syntax -- with an implementation

Frank Teusink (Frank.Teusink@cwi.nl)
Thu, 2 Jun 1994 09:11:34 GMT

Donald Beaudry <don@vicorp.com> writes:
>>>>>> On Wed, 1 Jun 94 12:09:37 MDT, lutz@KaPRE.COM (Mark Lutz) said:

>The most compelling reason that I have heard is that, as-is, you
>cannot reconstruct a properly indented program from an improperly
>indented one. I agree that Python's indentation-based syntax model is
>not only elegent, but is also very useful. That is why I did not
>propose to eliminate. I would like to simply agument it in such a way
>as to eliminiate its only major flaw.

You also cannot reconstruct a properly parenthesized program from an
improperly parenthesized one. It's exactly the same problem. So, you
propose to use block delimiters *and* indentation? What if the two
schemes collide? You have detected an inconsistency, but you still
can't automatically resolve it. You can choose to give one of the two
schemes priority over the other. But that's the same as just using one
of the two schemes, and use the second one for redundancy reasons.
There's no need to enforce both schemes.

Moreover, some people seem to want to replace indentation by block
delimiters.

>It is quite a bit easier to fix up the indentation of a C program than
>it is to fix up the indentation of a Python. Given a good set of
>"style-rules" and a messed up C program, there is only one way to fix
>up the indentation. Given Python's current syntax and a messed up
>Python program, there are many ways to fix it up... and each means
>somthing different. To properly re-indent a Python program you must
>read the code and figure out which of the many possible combinations
>is the right one.

What if the parenthesis are wrong? A Python program with missing indentation
is as bad as a C-program without parenthesis. In Python indentation is part
of your program. Don't lose it ;-)
So, in C programmers use some indentation, to get a better layout, and see
what they are doing. In Python, you can choose to use # end's, to get some
redundancy. It's the other way around. It's not worse.

>We both seem to agree that Python has this feature that makes it
>superior. But, what exactly is this feature? I think that the
>feature we are talking about is the required indentation/formatting
>that Python's syntax enforces. You seem to identifying this feature
>as the lack of an 'end' statement.

So you are on the path of enforcing both indentation and block delimiters.
I can see that that is useful in some cases (big programs, etc), but
please don't enforce it. Pyhton is (also) meant as a shell-language.
Enforcing delimiters *and* indentation together, seems lethal to me.
As an alternative, use # end's, and rewrite Guido's filter to check for
propper indentation. No change of language needed. In fact, this would
be the same as companies enforcing indentation-styles for C. It's just
the other way around.

>Python already has a 'begin' statement... it is written as a colon.
>The 'begin' is interpreted relative to its position within the code,
>that is, move the code, the 'begin' moves with it. But the current
>version of the 'end', the DEDENT token, is an absolute value, and is
>not relative to its context, move the code and the DEDENT does not
>know that it was moved. This adds an element of asymmety to the
>language that I feel should be removed.

I can't see what's different from not moving a closing parenthesis.
Instead of moving a closing parenthesis, you have `move' a column of
tabs.

>What makes you think that those who are "trying to tamper with the
>syntax" have not used the current syntax? Do you really believe that
>the current syntax is so good that no one who has used it would ever
>propose to change it? I have written quite a bit of Python code over
>the past year or so. I will admit that as it stands it is very easy
>to read Python code. But I find it annoyingly difficult to edit.
>Also, I don't see how you can say that my proposal is an attempt to
>make Python look like C, Ada maybe, but even that is stretching it a
>bit. I do vaguely remember that someone had submitted, and
>subsequently withdrawn, a proposal which essentially amounted to
>changing Python to C, but this is not what I am proposing.

I can't say I have particular problems with editing Python. Note that if
you want to enforce indentation and block delimiters, it won't become
easier. If you replace indentation by block delimiters, without enforcing
layout, programs become more difficult to read. I'd put the burden at the
end of the one editing, not at the one reading.

>Well I am glad to see that you have an open mind.

Don't know about Mark Lutz, but I just had brain surgery ;-)

Frank Teusink
frankt@cwi.nl

P.S. Although I am from CWI, I have nothing whatsoever to do with Python.
I just use it sometimes. And I like it as it is.