Call by binding [was re: [Tutor] beginning to code]
ROGER GRAYDON CHRISTMAN
dvl at psu.edu
Mon Sep 25 14:05:33 EDT 2017
More information about the Python-list mailing list
Mon Sep 25 14:05:33 EDT 2017
- Previous message (by thread): Call by binding [was Re: [Tutor] beginning to code]
- Next message (by thread): [Tutor] beginning to code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I would claim that these two paragraphs do not agree. What is stored in the variable in Pascal? In declared variables and value parameters, the value itself. Let's just temporarily stipulate that for reference parameters and pointer variables actually store a pointer to the object. Where is it recorded whether this is a pointer to an integer or a float or a character or a thingamajig? Neither in the value nor the assumed pointer to the variable. In Pascal (and most compiled languages) that value type is maintained separately by the compiler, and then discarded in the compiled code. In the case of Python, the 'pointer' you refer to also has no type information. Instead, the type of the value is frequently inferred at run-time, based on additional information stored with the value. There is no equivalent information available at run-time in Pascal. Now, when you say 'Python's assignment semantics are wholly contained by those of Pascal', please show me the equivalent Pascal code to mimic the following (and not by defining a brand new complex object type in Pascal, since I am not doing so in Python). x = 5 x = 'abc' I think the larger discussion was about value and reference parameters. Yes you can do both of those in Pascal. But if you were stuck with just those two choices, which applies to this function definition? def add_to_self(arg): arg += arg x = 'abc' add_to_self(x) # now x = 'abcabc' x = 5 add_to_self(x) # x is still 5 is 'arg' a value parameter or a reference parameter? Can you replicate this behavior in Pascal without any if statement, since, as you say, the semantics are wholly contained by those of Pascal (aside from the += operator itself not appearing in the Pascal language) Roger Christman Pennsylvania State Universtiy On Mon, Sep 25, 2017 12:00 PM, python-list at python.org wrote: > A pointer to the object is stored in the variable. > >Of course, I'm using terminology that is not conventional in Python >circles. However, I'm doing it to demonstrate that there's nothing >particularly different between Python's assignment semantics and those >of, say, Pascal. Python's assignment semantics are wholly contained by >those of Pascal. > >
- Previous message (by thread): Call by binding [was Re: [Tutor] beginning to code]
- Next message (by thread): [Tutor] beginning to code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list