[Python-Dev] Pragma-style declaration syntax (original) (raw)

M.-A. Lemburg mal@lemburg.com
Mon, 28 Aug 2000 21:29:04 +0200


Skip Montanaro wrote:

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.

True, I see the pragma statement as directive. Perhaps its not the best name after all -- but then it is likely not to be in use in existing Python programs as identifier, so perhaps we just need to make it clear in the documentation that some pragma statements will carry important information, not only hints.

-- Marc-Andre Lemburg


Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/