Python Feature Request: Explicit variable declarations
aleax at mac.com
Sun Apr 15 05:07:38 CEST 2007
Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> In Python, the "variable" NAME does NOT define storage; unlike most
> other classical languages where the "variable name" is a storage
> address, and the value of the RHS is COPIED to that address. Python does
> not do such copying. Names are references to the RHS object itself.
Right, but that's just like today's most popular languages -- Java and
C# -- with the one difference that in those languages "boxed" types
(elementary numbers, in Java) have different semantics.
> Languages with "variable declarations" are pre-allocating object
> space that can only hold objects of that type (ignoring VB "variant").
Again, this is not true for the most popular languages, Java and C# --
in those cases, excepting boxed types, variable declarations are
"pre-allocating" space for references, which can refer to any type
derived from theirs (so, e.g., in Java, "Object x;" means x can refer to
anything at all except a boxed type such as float).
I think you're confusing two issues with languages' underlying models:
boxes (C, Fortran, etc) vs tags (Java, Python, etc) for variables; and
declarations vs not. APL uses boxes but no declarations, etc, etc: you
can find all four variants!-)
More information about the Python-list