[Python-Dev] #pragmas in Python source code

gvwilson@nevex.com gvwilson@nevex.com
Wed, 12 Apr 2000 17:01:04 -0400 (EDT)


> Ka-Ping Yee wrote:
> Python isn't just a parse tree.  It has semantics.
> XML has no semantics.  It's content-free content.  :)

Python doesn't even have a parse tree (never mind semantics) unless you
have a Python parser handy.  XML gives my application a way to parse your
information, even if I can't understand it, which is a big step over (for
example) comments or strings embedded in Python/Perl/Java source files,
colon (or is semi-colon?) separated lists in .ini and .rc files, etc.

(I say this having wrestled with large Fortran programs in which a
sizeable fraction of the semantics was hidden in comment-style pragmas.
Having seen the demands this style of coding places on compilers, and
compiler writers, I'm willing to walk barefoot through the tundra to get
something more structured.  Hanging one of Barry's doc dict's off a module
ensures that key information is part of the parse tree, and that anyone
who wants to extend the mechanism can do so in a structured way.  I'd
still rather have direct embedding of XML, but I think doc dicts are still
a big step forward.)

Greg

p.s. This has come up as a major issue in the Software Carpentry
competition. On the one hand, you want (the equivalent of) makefiles to be
language neutral, so that (for example) you can write processors in Perl
and Java as well as Python. On the other hand, you want to have functions,
lists, and all the other goodies associated with a language.