[Python-Dev] "declare" reserved word (was: pragma)

M.-A. Lemburg mal@lemburg.com
Sat, 02 Sep 2000 16:01:15 +0200

Fredrik Lundh wrote:
> mal wrote:
> > I gave some examples in the other pragma thread. The main
> > idea behind "declare" is to define flags at compilation
> > time, the encoding of string literals being one of the
> > original motivations for introducing these flags:
> >
> > declare encoding = "latin-1"
> > x = u"This text will be interpreted as Latin-1 and stored as Unicode"
> >
> > declare encoding = "ascii"
> > y = u"This is supposed to be ASCII, but contains  Umlauts - error !"
> -1

On the "declare" concept or just the above examples ?
> for sanity's sake, we should only allow a *single* encoding per
> source file.  anything else is madness.

Uhm, the above was meant as two *separate* examples. I completely
agree that multiple encodings per file should not be allowed
(this would be easy to implement in the compiler).
> besides, the goal should be to apply the encoding to the entire
> file, not just the contents of string literals.

I'm not sure this is a good idea. 

The only parts where the encoding matters are string
literals (unless I've overlooked some important detail).
All other parts which could contain non-ASCII text such as
comments are not seen by the compiler.

So all source code encodings should really be ASCII supersets
(even if just to make editing them using a plain 8-bit editor

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