[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I'm wrong or Will we fix the ducks limp?

Marko Rauhamaa wrote:
 > [concerning leashed puppies]
> Note: no boxes! However, there are strings attached. Now you can truly
> *bind* objects to variables.

If you wanted to really bind them good and proper,
you'd use duct tape (or "duck tape" as some people
call it -- arguably more appropriate in this context!)

> Seriously, though, it is notable that the high-level programming
> languages pretty unanimously refuse to make variables first-class
> objects. I wonder why.

That's an interesting question. One reason might be
that in the absence of static type analysis, assigning
to a variable holding a reference to another variable
would be ambiguous. For example, suppose Python had
an & operator that gives you an object referring to
a variable somehow. Then, after

a = 42
b = 17
c = &a
c = &b

does 'c' now hold a reference to the variable 'b', or
does it still hold a reference to 'a' and 'a' now
holds a reference to 'b'?

Somehow these two operations would have to be spelled
different ways, which means you would need to know
whether you were dealing with a variable reference or
not. So they wouldn't really be first-class, in the
sense of being treated on an equal footing with
ordinary variables.