[issue46419] Incomplete Comparison to C++ Methods

2022-01-17 Thread Jorgen Harmse


New submission from Jorgen Harmse :

The description of classes mentions twice that methods are like C++ virtual 
member functions, but the truth is a bit stranger.

Even __init__ seems to act like a virtual function, so there is no guarantee 
that the base-class part of a derived-class instance is properly constructed.

Even if the base class __init__ is called, it may behave erratically. The 
object is already considered to belong to the derived class, so any method 
calls will resolve to the derived class. In C++, the run-time type inside any 
constructor or destructor always matches the compile-time type. Derived-class 
members are not called because those methods would attempt to use parts of the 
object that haven't been constructed yet or have already been destructed. 
Python takes no such precautions, and programmers should be warned accordingly. 
(I think the solution is to be very careful of calling any other method from 
__init__.)

--
assignee: docs@python
components: Documentation
messages: 410823
nosy: docs@python, jharmse
priority: normal
severity: normal
status: open
title: Incomplete Comparison to C++ Methods
type: enhancement
versions: Python 3.11

___
Python tracker 
<https://bugs.python.org/issue46419>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46419] Incomplete Comparison to C++ Methods

2022-01-21 Thread Jorgen Harmse


Jorgen Harmse  added the comment:

There may be more people who use Python, but there are strange semantics that 
cause problems even for experienced Python programmers. For example, 
assign-by-reference (apparently built without considering the solutions 
available in MatLab & R) frequently leads to unexpected changes in the caller's 
space. I expect that very few people understand linearisation, so multiple 
inheritance is effectively unusable in Python. C++ would generate a 
compile-time error if two base classes provided the same method (unless they 
inherited it from a common virtual base class).

The text in question appears twice in Section 9 of 
https://docs.python.org/3/tutorial/classes.html. It's in the third paragraph of 
the introduction and the 5th text paragraph of Section 9.5.

--

___
Python tracker 
<https://bugs.python.org/issue46419>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46419] Incomplete Comparison to C++ Methods

2022-01-21 Thread Jorgen Harmse


Jorgen Harmse  added the comment:

Is van Rossum serious? I responded to the comments on my report. The action is 
to clarify the documentation, probably including a warning against multiple 
inheritance.

--

___
Python tracker 
<https://bugs.python.org/issue46419>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com