[Python-Dev] Pragma-style declaration syntax

Skip Montanaro skip@mojam.com (Skip Montanaro)
Mon, 28 Aug 2000 14:17:47 -0500 (CDT)


    MAL> Here are some possible applications of pragmas (just to toss in
    MAL> a few ideas):

    MAL> # Cause global lookups to be cached in function's locals for future
    MAL> # reuse.
    MAL> pragma globals = 'constant'

    MAL> # Cause all Unicode literals in the current scope to be
    MAL> # interpreted as UTF-8.
    MAL> pragma encoding = 'utf-8'

    MAL> # Use -OO style optimizations
    MAL> pragma optimization = 2

    MAL> # Default division mode
    MAL> pragma division = 'float'

Marc-Andre,

My interpretation of the word "pragma" (and I think a probably common
interpretation) is that it is a "hint to the compiler" which the compiler
can ignore if it chooses.  See

    http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?query=pragma

Your use of the word suggests that you propose to implement something more
akin to a "directive", that is, something the compiler is not free to
ignore.  Ignoring the pragma in the first and third examples will likely
only make the program run slower.  Ignoring the second or fourth pragmas
would likely result in incorrect compilation of the source.

Whatever you come up with, I think the distinction between hint and
directive will have to be made clear in the documentation.

Skip