[Types-sig] Static name checking
Sun, 05 Dec 1999 13:28:15 -0500
I stand by my position that static type checking is not possibile
without static name checking.
Therefore I have begun to think what static name checking would require.
It isn't as draconian as what I suggested before.
Functions, modules and variables can be declared "static". In current
Python this would be done like this:
def foo( a ):
Frozen names can only refer to names in frozen namespace. Frozen
namespaces cannot be changed at runtime. They may not refer to names in
regular ("dynamic") namespaces. The namespaces may be in the same or
other modules. Therefore, they can be checked without actually loading
the module or instantiating the class. Aliases for frozen namespaces
should also be frozen automatically.
A frozen name checker would work by loading a document and parsing it
looking for every reference to the name "frozen". Then it would look at
the next line and verify that all referenced objects really are frozen.
Then it would check that frozen namespaces are not modified. Of course a
frozen name checker isn't trivial but it also isn't brain surgery.
Anyone bored and underworked out there?
From there, we could move to a first-class frozen keyword in Python 1.6:
frozen def foo(a):
return string.replace(a, "b" )
The definition of frozen objects cannot depend on runtime state like
frozen def foo(a):
frozen def foo(b):
So frozen functions and classes should be top-level. Methods in a frozen
class are frozen.
The word "freeze" already has baggage in the Python world but my second
choice "static" does also.
I am not voting for or against the continuation of the types-sig. At
this point we probably need code more than talk.
Paul Prescod - ISOGEN Consulting Engineer speaking for himself
Math -- that most logical of sciences -- teaches us that the truth can
be highly counterintuitive and that sense is hardly common.
K.C.Cole, "The Universe and the Teacup"