Thoughts on new grammar rules (PEP 284 in particular)

Steve Horne steve at lurking.demon.co.uk
Tue May 14 09:17:01 EDT 2002


On Fri, 10 May 2002 19:32:17 +0200, holger krekel
<pyth at devel.trillke.net> wrote:

>Tell us the truth! You were sent from these evil perl-hackers
>on a quest to bring python to perl's line-noise levels :-)

Nope - I hate perl.

The basis is taken from XML (or, alternately, LISP).

In a manual, it is much easier to look up a name than a combination of
operators. For instance, on the first reading of Python code, if you
did not know that the '{', ':', and '}' tokens combined to define
dictionaries, it would be a bit of a pain to look up in the manual
while trying to read some source code. You wouldn't know to look up
'dictionary' because you wouldn't know it's a dictionary.

For such a fundamental feature as dictionaries the answer is 'read the
beginners tutorial', but with more obscure features an answer of 'read
the entire Python documentation' is unreasonable to say the least.

My idea is not practical for everyday features, and I'm not suggesting
it for that. The Python language is already more than rich enough to
support most everyday programming tasks easily. But it allows new
features to be added, and it's no less readable than an calculation
with a few redundant parentheses surely. As such, surely it's better
than performing ever-more-extreme contortions with the existing
keywords and operators, as is already noticable in some PEPs.

Of course, with 20/20 hindsight, a much better approach could have
been taken. For instance, consider the following...

  begin function ... :
    ...

  begin while ... :
    ...

And, relevant to a current PEP...

  begin switch ... :
    begin case ... :
      ...

    begin default :
      ...

and because only 'begin' would be a keyword ('procedure' etc being
ordinary identifiers, which only have special meaning after the
'begin' keyword) any new structure could be added without needing new
keywords or obscure operator combinations - old code would be safe
from at least one aspect of the evolution of the language.

By using 'begin' to make the start of a structure explicit, the ':'
could also probably be dropped. I'm always forgetting them things
(whinge whine...).

So using perlish symbols isn't by any means my ideal - I just think
that in the long run there may already be a risk of serious creaping
perlishness (due to the resistance to adding new keywords), and this
would be a way of saying 'this far, but no further'.

-- 
Steve Horne
steve at lurking.demon.co.uk



More information about the Python-list mailing list