Yegappan wrote:
> When creating an instance of a child class, the parent class new() > function is not invoked. How do we invoke the parent class new() > function from a child class new() function to perform some > initialization? At this moment you can't. The simplest is to move the initializations into a separate function and call it from any new() function where it is to be used. I could not find a simple and consistent way of calling a constructor of the parent class. In some languages it is mandatory, often there are restrictions and requirements for the order in which things happen. Keep in mind there may be several constructors to choose from. In most cases this should be fine, but perhaps sometimes you want to make sure that the parent class always gets initialzed in a certain way, and extending it should not make it possible to skip that. Is that important enough to add a rule for? These things quickly get complicated. For example the TypeScript documentation says: "Each derived class that contains a constructor function must call super() which will execute the constructor of the base class. What’s more, before we ever access a property on this in a constructor body, we have to call super(). This is an important rule that TypeScript will enforce." The simplest would be that the parent constructor is always called first. However, it usually has arguments and those need to be passed somehow. Is there a language where this works nicely and we do it like that in Vim? -- hundred-and-one symptoms of being an internet addict: 19. All of your friends have an @ in their names. /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20230115201920.BA45F1C091A%40moolenaar.net.
