[fpc-pascal] Traits Proposal

Martin Frb lazarus at mfriebe.de
Wed Feb 10 18:17:16 CET 2021


On 10/02/2021 16:59, Ryan Joseph via fpc-pascal wrote:
> • PHP (trait): https://www.php.net/manual/en/language.oop5.traits.php
>

The example exposes another aspect:

> |trait SayWorld {
>     public function sayHello() {
> parent::sayHello();|

|In this case the trait has access to the object/class into which it is 
embedded. (otherwise it could not call the inherited method of the outer 
class).

Is that wanted?
(methods and fields?)

If that is wanted....
- If it will be using the existing "object" (or advanced record), then 
such code is not possible.
- One might have to think about how to declare what a trait can access?
    Just allow anything in the code, and attempt to resolve when the 
trait is embedded? IMHO maybe not?

|
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210210/1de84fbd/attachment.htm>


More information about the fpc-pascal mailing list