IWETHEY v. 0.3.0 | TODO
1,095 registered users | 2 active users | 3 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Not really missing anything.
I don't know how a superclass could decide which child class to intantiate if there isn't some sort of "case"-type logic in the superclass constructor.


But in Python, for example, it isn't the superclass which decides, usually. The interpreter passes the target subclass (as an argument) to the superclass constructor. In most cases (if you're not mucking about with metaclasses), the superclass doesn't have to do the switching.

In the case of overriding methods, the interpreter walks the MRO (superclass heirarchy) of the object instance at runtime to figure out which method to run.

If anyone knows how Java or C# do it, I'd love to be enlightened. :)
New VMT in C++
Virtual Method Table.

For single inheritance, the simplest thing in the world: first word in object is a pointer to the table of its methods' entry points. One table per class, the pointer is set in constructor.

For multiple inheritance it gets hairy as hell.
--

... a reference to Presidente Arbusto.
-- [link|http://itre.cis.upenn.edu/~myl/languagelog/archives/001417.html|Geoffrey K. Pullum]
     Lines of code in a Java method ... - (bluke) - (73)
         I don't know of studies of this with OO languages - (ben_tilly) - (64)
             I remember that when I read Code Complete ... - (bluke) - (60)
                 Hence my speculation about how and why to change that for OO -NT - (ben_tilly) - (59)
                     In OO code many of the decision points ... - (bluke) - (58)
                         Quibble - (ben_tilly) - (57)
                             Okay, thought it was just me - (drewk) - (46)
                                 Not really missing anything. - (FuManChu) - (1)
                                     VMT in C++ - (Arkadiy)
                                 The superclass decides nothing - (ben_tilly) - (43)
                                     Once again, it's the terminology - (drewk) - (40)
                                         That's not multiple inheritance - (ben_tilly)
                                         Ramble ramble ramble - (FuManChu)
                                         Yes and No - (bluke) - (37)
                                             I mis-read Ben - (drewk) - (36)
                                                 You misunderstand interfaces and factories ... - (bluke) - (2)
                                                     Drew is right. - (FuManChu) - (1)
                                                         My point was - (bluke)
                                                 I'm actually on the fence - (ben_tilly) - (32)
                                                     That is with implementation inheritance - (bluke) - (2)
                                                         That is both with interface and implementation inheritance - (ben_tilly) - (1)
                                                             With interfaces it is less of a concern - (bluke)
                                                     Hadn't heard of LSP - (drewk) - (28)
                                                         Huh? - (tuberculosis) - (27)
                                                             Don't get all religious on me - (drewk) - (26)
                                                                 Going to disagreed on this point - (JimWeirich) - (1)
                                                                     agreed - (deSitter)
                                                                 Re: Don't get all religious on me - (JimWeirich) - (23)
                                                                     And that's the key point - (ben_tilly) - (22)
                                                                         Someday I've got to take a class - (drewk) - (21)
                                                                             ..when I get my inheritance -NT - (deSitter)
                                                                             Yup. No generic substitute for that. -NT - (FuManChu)
                                                                             Good idea in this instance. - (admin) - (14)
                                                                                 I object; it's part of a general pattern -NT - (FuManChu) - (13)
                                                                                     Ah, but I have a cunning strategy... - (admin) - (12)
                                                                                         Bah. Overridden. - (FuManChu) - (1)
                                                                                             Overloaded your capacity for understanding, eh? - (admin)
                                                                                         Ashton, is that you? - (Another Scott) - (7)
                                                                                             Better than the treasurer... - (admin) - (6)
                                                                                                 He'll have to wait - I'm collecting garbage - (ben_tilly) - (5)
                                                                                                     Coincidentally, there's a fellow around here named Mark... - (admin) - (4)
                                                                                                         I'm sorry but that pointer is dangling - (ben_tilly) - (3)
                                                                                                             Some people have too much time on their hands... - (static) - (2)
                                                                                                                 You're a real LALRf riot. - (admin) - (1)
                                                                                                                     So you sed. Personally, I think it's a Perl in the Blinker. -NT - (Another Scott)
                                                                                         Uuuuuhh... - (jb4)
                                                                                         The cun.. er, clever linguist suffers Code 715 - (Ashton)
                                                                             Or an interface - (tuberculosis) - (2)
                                                                                 Yes, and that's what we do - (drewk) - (1)
                                                                                     Language doesn't need to support abstract class - (tuberculosis)
                                                                             That was not what I meant - (bluke)
                                     It's a decision, but it's abstracted out - (Arkadiy) - (1)
                                         Yes, but I don't care how it works - (bluke)
                             DP's are compressed in OO - (tuberculosis) - (6)
                                 Polymorphism relies on a lie - (tablizer) - (5)
                                     Re: Polymorphism relies on a lie - (admin) - (2)
                                         Mostly, it is - (tablizer) - (1)
                                             To the naive programmer, perhaps. - (admin)
                                     Something tells me you'd like prototype OO as a midground -NT - (FuManChu) - (1)
                                         *No-one* can eat that much crow -NT - (pwhysall)
                             We had a big fight over case-vs-poly a few years ago -NT - (tablizer) - (2)
                                 Charley Rock Tree - (ChrisR) - (1)
                                     Ha! :-) -NT - (Another Scott)
             Re: I don't know of studies of this with OO languages - (deSitter)
             Interesting comment by Ron Jeffries - (bluke) - (1)
                 Re: Interesting comment by Ron Jeffries - (deSitter)
         to minimize the damage that these kind of developers wreak - (Arkadiy) - (1)
             Unfortunately I can't - (bluke)
         4. -NT - (FuManChu) - (2)
             In smalltalk that might be realistic - (bluke) - (1)
                 That was my point. Glad someone got the joke :) -NT - (FuManChu)
         1/2 page - (tuberculosis)
         Re: Lines of code in a Java method ... - (dshellman) - (1)
             Agree - (bluke)

A:>_
99 ms