list storing variables

Marko Rauhamaa marko at pacujo.net
Mon Feb 23 15:25:06 EST 2015


Chris Angelico <rosuav at gmail.com>:

> On Tue, Feb 24, 2015 at 6:06 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> What I'm saying is that there's nothing special about Python's object
>> model or variables. Guido could decide tomorrow to add a C-esque "&"
>> operator to Python without breaking a single existing Python program.
>> The Python compiler would simply generate code like above.
>
> Actually, there's a fairly huge difference. All you've done is create
> a thing which can set a global... you don't have any way to pass
> pointers around, like you can in C.

That AmpersandA() object *is* a first-class "pointer" object. It can be
passed around freely just like &A in C.

> You have to construct a dedicated "thing" in your source code for
> every pointer you want to be able to work with.

Yes. Python doesn't have language-level support for the construct, but
it could be added without a change in the data model.

> And if you try to make a single generic "Ampersand" class, what
> you'll find is that you're working with namespaces, not addresses.

I wasn't trying to make a single generic Ampersand class.

> So Python's name-binding model really is fundamentally different from
> C's stuff-in-memory model.

I still fail to see the fundamental difference.

The main difference between the "old" languages and the "new" languages
is the lack of "boxing" in the "new" languages. In C terms, Python's "."
is C's "->".


Marko



More information about the Python-list mailing list