|
2012-05-30
| ||
| 17:32 | • Ticket [2952145fff] Constructor call chain configuration status still Closed... artifact: 4e084599e3 user: dkf | |
|
2010-03-02
| ||
| 09:20 | • Closed ticket [2952145fff]. artifact: 9281b1e5bc user: sf-robot | |
| 09:20 | • Ticket [2952145fff]: 4 changes artifact: 528ef49898 user: sf-robot | |
|
2010-02-15
| ||
| 23:13 | • Pending ticket [2952145fff]. artifact: 91f476b781 user: dkf | |
| 23:13 | • Ticket [2952145fff]: 4 changes artifact: 692ad3cf00 user: dkf | |
| 15:56 | • New ticket [2952145fff]. artifact: 496e56937d user: apnadkarni | |
Constructor call chain configuration
Closed / Fixed2952145fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 15 years ago
Descriptionplain2010-02-15 15:56:49
A posting by Martin Lembourg in c.l.t leads to the following question - how does one implement the following scenario: Two independent classes A and B and a class C that derives from both of them. I want to be able create objects of each of these classes. When I create an object of class C, constructors for both A and B must be called. The issue is that ( assuming the statement "superclass A B" in C's definition), if A's constructor has a command "next", the statement "A create foo" raises an error "no next constructor implementation". If we remove the "next" command from A's constructor, then "A create foo" works but then when doing "C create bar", the constructor for B does not get called (presumably because A's constructor no longer has a next statement). So how does one write code to meet the above requirements ? (tested with CVS HEAD as of Feb 15 2010) /Ashok
dkfplain2010-02-15 23:13:29
I hate these sorts of questions. The (hardline ontological-theoretic) answer is that if A and B are truly wholly independent classes, C has no business deriving from both of them. If they are not that separate, make both A and B derive from a common parent class and the problem goes away. If you wish to argue that I'm wrong, feel free. Demonstrate a specific example where it matters. Not a theoretical example either; while I know it is certainly possible to create code that will fail in the circumstances outlined, my whole point is that code that is going to be working sanely will not actually need to do so. Thus a combobox widget can be considered to be a subclass of entry, but not of listbox. (The listbox-ness is best held in another widget that is delegated to, with forwarded methods doing the delegation.)
dkf Pending ticket [2952145fff].
[History diff]2010-02-15 23:13:30
sf-robotplain2010-03-02 09:20:40
This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
sf-robotplain2010-03-02 09:20:41
allow_comments - 1
dkfplain2012-05-30 17:32:23
TIP #381 introduced [nextto], which can be used in constructors to do exactly this sort of thing.
Log in (anonymous is fine) to add a comment.