Well I can't say I like your choice of tokens (why on earth '$='? Why
the reversed closing quote?) but that's esthetics -- otherwise it
SEEMS not too controversial so far.
> Definition of long strings only allowed outside of function
> definitions & so forth. Assignment or usage is dereferenced at compile
> time, not runtime, to get around the desire to have long strings in
> function w/o a global lookup. If another module imported the above:
> import example
> example.S = ''
> This would output the original message twice. Once a module was
> compiled, if one did not 'del S' in the module, or otherwise assign a
> value to 'S', then the long string would be available in the global
> namespace of the module, though it would act like a normal string.
In one word: EVIL. It would probably require semi-massive change to
the compiler. And the restriction that this construct can only be
used outside function defs is a first for Python (All of 'import',
'class' and 'def' can be used anywhere, conditional, inside methods,
you name it.)
> What I am basically proposing is a syntax, and a optimization with a
> simple side effect.
> If you wanted to avoid the side-effect and optimization, you could:
> S $=
> A short string or a long string.
> S = S
> def show_example():
> Here, the runtime value of S would be used.
You are changing the semantics of names in an ad-hoc fashion here.
Why should this be done for strings only? I'd be much happier with a
proposal for a different string quote ONLY.
> The basic goal is to keep ugly strings out of the code...
You could do that with triple quotes by a programming convention.
> If you really like triple quotes (ick ick ick), then gimme a
> compile-time dereference operator. Heck.. give us one anyway. I'd like
> to be able to know that my modules are using the values in their
> globals that I put there, rather than modified ones.
> i = 5
> def f():
> print *i
> i = 6
> produces '5'
Actually, there will be a way to do this in 1.0.2 using default
parameters, more or less:
i = 5
i = 6
And if you're looking for a language that makes it impossible for
users to pervert the environment in which modules run... Try Ada.
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>