A question on modification of a list via a function invocation
Chris Angelico
rosuav at gmail.com
Fri Aug 18 13:28:33 EDT 2017
On Sat, Aug 19, 2017 at 2:06 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>>Wrong. Your parameter always contains an object. Sometimes that object
>>is an array, sometimes that object is null. Null is not the absence of
>>an object, any more than zero is the absence of a number, or black is
>>the absence of an image.
>
> »The reference values (often just references) are
> pointers to these objects, and a special null reference,
> which refers to no object.«
>
> The Java Language Specification 8, section 4.3.1
>
> (Maybe your are thinking of Python's »None«,
> which is something different than Java's »null«.)
I'm thinking of the abstract concept of a "value". Java differentiates
between "reference values" and "primitive values", where numbers and
strings are not reference values. The point of the above sentence is
that "null" is a special kind of reference value, as opposed to being
a kind of primitive value. But whether something is a reference or
primitive type, it's still a "value" in the abstract sense, and can be
passed as a parameter to a function.
Python simplifies things a lot here. Every value is an object. None is
an object, 42 is an object, "spam" is an object, [1,2,3] is an object,
and dict is an object. "Value" and "object" become virtually
interchangeable. But even in Java, where some things are objects and
some are not, they are still all values.
So I was slightly wrong in my terminology (I said "object" when it
would have been more accurate to say "value"), but I stand by the gist
of what I said there.
ChrisA
More information about the Python-list
mailing list