New PEP: The directive statement

Martin von Loewis loewis at informatik.hu-berlin.de
Thu Mar 22 04:41:48 EST 2001


Nathan Gray <n8gray at caltech.edu.is.my.e-mail.address> writes:

> Excellent work, Martin.

Thanks!

> Would you consider using this sort of syntax instead?
> 
>    directive_statement: "directive" directive_ID ("," directive_ID)* 
>                             [";"] NEWLINE
>    directive_ID:        identifier ("." identifier)*
> 
> I understand that there are those who want to keep things as dead-simple as
> possible, and there are good reasons for *not* wanting people to put multiple
> directives on one line

It would be certainly possible to make the directive statement a
simple_stmt, so you could write

directive foo; print "Hello"; directive bar "value"

As for extending the syntax of the directive statement itself: That
can be done when need occurs. As it stands, the compiler needs to be
taught every new directive on its own, so it may turn out that the
syntax is insufficient one day - just as the import syntax turned out
to be insufficient twice (adding packages first, and "import as"
recently).

Please note that the third element of a directive is an atom, which
allows quite some expressivenes.

> My second comment is that you may want to consider adopting a form of the 
> __future__ proposal's runtime semantics for directive statements.  Perhaps 
> 
>     directive transitional.nested_scopes
> 
> could create a "_Feature object" called nested_scopes identical to the one
> proposed in "back to the __future__".
> 
>     print nested_scopes.getOptionalRelease()   # prints "(2, 1, 0, 'beta', 1)"

I have my problems with that part of PEP 236 also. While it is
certainly possible to provide the release when a feature was first
released, it is not possible to give an accurate answer to the
question when it will become mandatory. The intent to make it
mandatory in the future should go into the documentation, IMO.

Furthermore, what is the use of that information to a program?

Regards,
Martin



More information about the Python-list mailing list