Official definition of call-by-value (Re: Finding the instance reference...)

rurpy at yahoo.com rurpy at yahoo.com
Fri Nov 14 17:16:55 EST 2008


On Nov 13, 4:53 pm, Terry Reedy wrote:
> rurpy at yahoo.com wrote:
>
>> I have yet to see any reasonable definition of a Python
>> value in the Python docs or elsewhere, despite the fact
>> that a value is one of the three defining characteristics
>> of an object, a central concept in Python.
>
> I noticed too.  My try:
>
> The value of an object is the information that the object represents (or
> that is stored with the object) that the interpreter uses to compute the
> value of a new object when you use the object in an expression.  For
> number objects, the number value.  For collection objects, the objects
> collected. For functions, the signature and function performed when called.
>
> How is that?

I am starting with the idea that "value" is what we call
whatever it is that is the difference between, for example,
the objects int(3) and int(4).  While your definition
seems to be saying something similar it does not seem
very precise.

How would I use your definition to answer the following
questions?

* How does an object get a value?

* Can I create an object that has a value that
 is the same as int(3) without somehow using an
 int(3) object in its construction?

* Do all objects have values? (Ignore the Python
 docs if necessary.)

* What is the value of object()?

* Does an object's behavior (methods) affect
 its value?

* If two objects have different unrelated types
 (i.e. not subclassed), are their values necessarily
 different (regardless of how they print, or act
 when used in an expression)?

* What if they aren't unrelated but one is a sub-
 class of the other?

* Can one completely hide an object's value by
 overriding methods?

* Can two objects have the same value, even if the
 methods of one have been overridden to hide it's
 value as completely as possible?

I wonder if all values come, directly or indirectly,
from "valued objects" created in the C-API?
Or perhaps value is some sort of useful but fundamentally
undefinable concept that disappears when looked at too
closely, leaving behind only state and behavior?



More information about the Python-list mailing list