[fpc-pascal] Traits Proposal
Ryan Joseph
genericptr at gmail.com
Sun Feb 14 19:03:46 CET 2021
> On Feb 14, 2021, at 10:20 AM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> To be fair, that *is* how inheritance works for example if you try to use OOP in C... (though it would be more like "sphere.parent.parent.Draw()")
and that was bad. :) in PHP you're forced to use this-> instead of implicit self and even that is annoying.
>
>> What it leaves desired:
>>
>> 1) Making a dummy interface is annoying boiler plate but not a deal breaker.
>
> Again, I see this is part of Pascal's declarativeness. Also this way you can make sure that only those methods/properties that you need are hoisted into the parent object allowing for easier reuse of existing classes/records/objects.
That is certainly true. With the idea of "default record properties"/traits the visibility sections like public would have to be used to define the exportable members. The "declarativeness" is also boiler plate but I do see your point. Not a deal breaker though but it may get tedious if you used this feature often.
>> I stand by that using some concept of traits/mixins does all the stuff we want with less boiler plate but I'm happy to explore any other ideas.
>
> One can explore further improvements down the road (e.g. fields), but we should provide a solid base first.
Yes, you're right properties do work but require the getter/settings methods.
Another question, what does overriding mean in this context of interface delegation? With "default implements" it would be possible to add a method with the same name, which should be an error but it opens a possibility to provide a new method implementation.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list