[Python-Dev] Pragma-style declaration syntax

Greg Wilson gvwilson@nevex.com
Mon, 28 Aug 2000 13:43:29 -0400 (EDT)


> > Marc-Andre Lemburg:
> > 1. Embed pragma declarations in comments:
> > 	#pragma: name = value
> > 
> > 2. Reusing a Python keyword to build a new form of statement:
> > 	def name = value
> > 
> > 3. Add a new keyword:
> > 	decl name = value

> Guido van Rossum:
> I say add a new reserved word pragma and accept the consequences.  
> The other solutions are just too ugly.

Greg Wilson:
Will pragma values be available at run-time, e.g. in a special
module-level dictionary variable '__pragma__', so that:

    pragma "encoding" = "UTF8"
    pragma "division" = "fractional"

has the same effect as:

    __pragma__["encoding"] = "UTF8"
    __pragma__["division"] = "fractional"

If that's the case, would it be better to use the dictionary syntax?  Or
does the special form simplify pragma detection so much as to justify
adding new syntax?

Also, what's the effect of putting a pragma in the middle of a file,
rather than at the top?  Does 'import' respect pragmas, or are they
per-file?  I've seen Fortran files that start with 20 lines of:

    C$VENDOR PROPERTY DEFAULT

to disable any settings that might be in effect when the file is included
in another, just so that the author of the include'd file could be sure of
the semantics of the code he was writing.

Thanks,

Greg