Earlier quoted context omitted.
No, no, no there is no "call by object." It is precisely this mistaken idea which muddies the waters, as you put it. Virtually all modern processors are stack-based architectures. All arguments to functions are passed on the stack or in registers. The only thing that can be placed onto the stack or into a register are numbers. Those numbers can represent either an actual value or an address in memory. The former is c…
It may be implemented as call-by-reference, but the semantics are not the same as what one thinks of when he hears that phrase.
Python, as Reviewed by a C++ Programmer
31–40 of 79 posts
Re: Python, as Reviewed by a C++ Programmer
#32Earlier quoted context omitted.
Claims that Python/C#/Java etc., are call by value where the 'value' is the value of the pointer does not help. It only muddies things. There really ought to be different name for such call semantics and there is. Its called call by object. In C++ lingo call by const pointer comes closest: one cannot change what the pointer points to. However the pointed object may not be a const
Python is "pass reference by value", in C++ semantics.
Re: Python, as Reviewed by a C++ Programmer
#33Rust is better than C++ at “if it compiles, it works” and has a great package manager, so as far as the topics highlighted here go, Rust seems to be the best of both worlds.
One thing where Rust is rather lacking is the missionarism of some people in the community.
Re: Python, as Reviewed by a C++ Programmer
#34Then, some systems cannot afford to have garbage collection, because it usually runs in an unpredictable amount of time. Such systems are for example real-time systems. In those cases a language like C++ is a good fit.
Re: Python, as Reviewed by a C++ Programmer
#35Earlier quoted context omitted.
No, no, no there is no "call by object." It is precisely this mistaken idea which muddies the waters, as you put it. Virtually all modern processors are stack-based architectures. All arguments to functions are passed on the stack or in registers. The only thing that can be placed onto the stack or into a register are numbers. Those numbers can represent either an actual value or an address in memory. The former is c…
Yes. But. Language designers go out of their way typically to hide this underlying truth, by for example implementing "call by value" when the type of the value is "Customer" or whatever.
Re: Python, as Reviewed by a C++ Programmer
#36It is possible to add annotations to your code like
class Foo:
x: int
# ...
and then run type checks using `mypy`, so that for the annotated code probability of the "passes the checks => won't crash the runtime" case is much larger.Re: Python, as Reviewed by a C++ Programmer
#37Earlier quoted context omitted.
Claims that Python/C#/Java etc., are call by value where the 'value' is the value of the pointer does not help. It only muddies things. There really ought to be different name for such call semantics and there is. Its called call by object. In C++ lingo call by const pointer comes closest: one cannot change what the pointer points to. However the pointed object may not be a const
No, no, no there is no "call by object." It is precisely this mistaken idea which muddies the waters, as you put it. Virtually all modern processors are stack-based architectures. All arguments to functions are passed on the stack or in registers. The only thing that can be placed onto the stack or into a register are numbers. Those numbers can represent either an actual value or an address in memory. The former is c…
Re: Python, as Reviewed by a C++ Programmer
#38Earlier quoted context omitted.
It may be implemented as call-by-reference, but the semantics are not the same as what one thinks of when he hears that phrase.
In what way are they different?
Re: Python, as Reviewed by a C++ Programmer
#39The article doesn't mention type annotations described in PEP484 and added to CPython since Python 3.5. It is possible to add annotations to your code like class Foo: x: int # ... and then run type checks using `mypy`, so that for the annotated code probability of the "passes the checks => won't crash the runtime" case is much larger.
So this might be helpful for code you wrote, but not anywhere it interfaces with other peoples' code (which, in my opinion, is probably the most important place to check for type errors).
Re: Python, as Reviewed by a C++ Programmer
#40Earlier quoted context omitted.
Claims that Python/C#/Java etc., are call by value where the 'value' is the value of the pointer does not help. It only muddies things. There really ought to be different name for such call semantics and there is. Its called call by object. In C++ lingo call by const pointer comes closest: one cannot change what the pointer points to. However the pointed object may not be a const
No, no, no there is no "call by object." It is precisely this mistaken idea which muddies the waters, as you put it. Virtually all modern processors are stack-based architectures. All arguments to functions are passed on the stack or in registers. The only thing that can be placed onto the stack or into a register are numbers. Those numbers can represent either an actual value or an address in memory. The former is c…