A question on modification of a list via a function invocation

Chris Angelico rosuav at gmail.com
Tue Sep 5 16:52:28 EDT 2017


On Wed, Sep 6, 2017 at 6:42 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>>here's a C program that actually MANIPULATES pointers:
> ...
>>x += 2;
> ...
>>You can in C. Can you in Java?
>
>   »dog = null« in Java would correspond to »x = 0« in C.
>
>   It seems, to you, an assignment of »x + 2« to »x« is
>   "manipulation", while an assignment of »0« to »x« is not.
>
>   Well, if you define the term "manipulation" to get the
>   results you intend, no one can prove you wrong, but your
>   words might be harder to understand when they do not use
>   the English meanings of words (like "manipulate") but your
>   ad-hoc meanings.
>

dog = null in Java corresponds to x = None in Python. It's a null
reference, but that's still a specific "thing". A fully compliant
Python implementation could use a NULL pointer to represent the None
object, as long as it correspondingly interprets such a pointer as
representing None.

In all of your Java examples, you're causing a name to refer to either
an object or null, and everything you do can be explained in terms of
name bindings Python-style.

ChrisA



More information about the Python-list mailing list