[Python-Dev] pragmas as callbacks

M.-A. Lemburg mal@lemburg.com
Tue, 29 Aug 2000 18:46:29 +0200


Greg Wilson wrote:
> 
> > Marc-Andre Lemburg wrote:
> > I'd rather not add complicated semantics to pragmas -- they should be
> > able to set flags, but not much more.
> 
> Greg Wilson writes:
> 
> That's probably what every Fortran compiler vendor said at first --- "just
> a couple of on/off flags".  Then it was, "Set numeric values (like the
> debugging level)".  A full-blown HPF compiler's pragmas are now a complete
> programming language, so that you can (for example) specify how to
> partition one array based on the partitioning in another.
> 
> Same thing happened with the C preprocessor --- more and more directives
> crept in over time.  And the Microsoft C++ compiler.  And I'm sure this
> list's readers could come up with dozens of more examples.
>
> Pragmas are a way to give instructions to the interpreter; when you let
> people give something instructions, you're letting them program it, and I
> think it's best to design your mechanism from the start to support that.

I don't get your point: you can "program" the interpreter by
calling various sys module APIs to set interpreter flags already.

Pragmas are needed to tell the compiler what to do with a
source file. They extend the command line flags which are already
available to a more fine-grained mechanism. That's all -- nothing
more.

If a programmer wants to influence compilation globally,
then she would have to set the sys module flags prior to invoking
compile().

(This is already possible using mx.Tools additional sys builtins,
e.g. you can tell the compiler to work in optimizing mode prior
to invoking compile(). Some version of these will most likely go
into 2.1.)

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/