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

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

On Mon, Jun 6, 2016, at 12:19, Steven D'Aprano wrote:
> (2) The "variables are like boxes" metaphor applies to static languages
> like
> C and Pascal, where the compiler has knowledge of what variables will
> exist. Such languages allocate space for the variables at compile time,
> usually using fixed memory locations on the stack, or in registers, but
> rarely dynamically in the heap.

As you're so fond of pointing out, those are implementation details. And
CPython does it too (using frame objects rather than the stack, but the
relevant point here is that it *does* have knowledge of what variables
will exist), for local variables.

> That's exactly what Python doesn't do.

And anyway, the fact that the "boxes" are dynamically allocated rather
than "fixed memory locations on the stack"* doesn't stop them from being
boxes (if you prefer Marko's analogy, "Some puppies hold leashes in
their mouths"). Attributes and list items and dictionary keys and values
are also boxes.

*isn't the whole point of it being a stack that they're not fixed? I
assume you meant fixed offsets from the stack frame.