A counter-proposal to __future__ in PEP 236
Alex Martelli
aleaxit at yahoo.com
Thu Mar 1 09:07:23 EST 2001
"Martin von Loewis" <loewis at informatik.hu-berlin.de> wrote in message
news:j47l29lpo8.fsf at informatik.hu-berlin.de...
[snip]
> In this implementation, directive is only considered as a keyword if
> it appears at the beginning of the module. Therefore, code that
> happens to use directive as an identifier will not break (unless it
> assigns to directive as the first thing in the module).
>
> I'd appreciate any comments as to whether this directive statement is
> better or worse for the purpose of indicating that nested scopes are
> used in a module.
It's indisputably much more explicit and direct. Recycling
'from/import' to mean something very different than other uses
of from/import is subtle and cute. This implies a huge plus
for the 'directive' patch.
Yes, 'directive' does theoretically imply possible code
breakage -- although, if it were possible to further
special-case things so that the directive statement
always took TWO or more directive-words, as in, e.g.
directive nested scopes
or
directive simple scopes
and/or took a colon, e.g.
directive: scopes nest
or
directive: no nesting
it might perhaps be possible to avoid breaking ANY code
that currently might be working by any stretch of the
imagination (I have not checked how hard it might be to
look-forward in the lexer so that only directive-colon
triggered the new keyword-token -- just reasoning in
the abstract). [It seems to me the colon would not
damage readability at all here -- on the contrary].
Even if the theoretical breakage of some hypothetical
old module starting with
directive = 23
or
directive, floopres = 23,42
was to be the price of avoiding the cuteness of
'from/import' "overloading", I would still vote for
directive (or, rather, against the overloading thing)
if I did have a vote in the matter. Such special cases
and cuteness are overdone in other languages (C++ and
its different uses of 'static' come to mind...), and
they're a bear to teach to newbies. The _semantics_
of PEP 236 are a great idea; I do earnestly hope there
is some way, ANY way, to avoid its syntax, and this
'directive' idea gives me a glimmer of hope...!
Alex
More information about the Python-list
mailing list