Yeah, that would be helpful for when you need to use a more compositive approach and when you want an object to take on multiple roles (e.g. some sort of mediator or controller). Currently you need to create subclasses for every role but those classes are only use once with the mediator for a single instance per mediator and have wrap them, manage them (since class instances must always be pointers), etc and this is a lot of verbose boilerplate code to avoid a limitation of the language. Interfaces help a tiny bit but they are very limited since you cannot have something like base roles that implement most of the generic functionality but leave specializations to the subclasses.
On Sat, Aug 19, 2017 at 10:49 AM, Ondrej Pokorny <[email protected]> wrote: > On 19.08.2017 9:27, Sven Barth via fpc-devel wrote: > >> The designers of Object Pascal decided on purpose against multiple >> inheritance as they probably saw the problems that C++ has with them. Even >> Java and C#, both clearly influenced by C++ don't support multiple >> inheritance. >> >> Just think about one class in the inheritance graph reintroducing a >> virtual method with different parameters. What will the final class do then? >> >> Nothing special. The new virtual method is just a completely different > method. Nothing to really bother about. Pascal supports overloading with no > problems. > > Actually what you get from the schema is a single inheritance chain. The > extension classes would be automatically inserted: > > TBase = class(TObject); > TBase_TAddressExtension = class(TBase); > TBase_TAddressExtension_TTagsExtension = class(TBase_TAddressExtension); > TCustomer = class(TBase_TAddressExtension_TTagsExtension); > > > Ondrej > _______________________________________________ > fpc-devel maillist - [email protected] > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel >
_______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
