[Python-ideas] binding vs rebinding

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Fri Feb 6 21:47:26 CET 2009

On Fri, Feb 6, 2009 at 20:43, Scott Dial
<scott+python-ideas at scottdial.com> wrote:

>> 1. Java - split
>> 2. C - split
>> 3. C++ - split
>> 6. C# - split
> Are you counting the implicit lack of a binding as a binding?

I am treating as "split" languages which distinguish introducing a new
variable in the current scope from assignment to an existing variable.

Or, in other words, languages where assignment alone cannot be used to
create a new local variable.

When a variable is introduced, its value can be given explicitly, or
it can be assumed to be some default (possibly depending on the type),
or it can be unspecified, or it can require further rebinding. Usually
there is a choice between the first and some of the others. I do not
consider these differences.

> "int x;" does not bind anything to "x",

It creates an object of type int and binds the name x to it. The
object initially has an unspecified value, and can have its value
changed. The association between usages of x in this scope and this
object cannot be changed.

>> 4. (Visual) Basic - split
>> 8. Perl - split
>> 9. JavaScript - split
>> 10. Delphi - split
> In addition to the debate above, the declarations are optional in these
> languages, and in that case, they are very much the same semantics as
> Python.

In Perl you can assign to an non-existing variable, which is in this
case assumed to be global (and you get a warning if warnings are
turned on). In non-trivial programs they are local variables which

For JavaScript:

For Visual Basic: http://msdn.microsoft.com/en-us/library/1t0wsc67(VS.80).aspx

For Delphi: http://delphi.about.com/od/beginners/l/aa060899.htm

All these languages have a syntax for introducing a variable, distinct
from assignment to an existing variable, and that syntax is needed for
creating a local variable in a function scope.

Marcin Kowalczyk
qrczak at knm.org.pl

More information about the Python-ideas mailing list