[fpc-pascal] Traits Proposal

Sven Barth pascaldragon at googlemail.com
Wed Feb 17 14:10:10 CET 2021


Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Mi., 17. Feb. 2021, 02:15:

>
>
> > On Feb 16, 2021, at 2:43 PM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > FPC currently does not yet support class types not to mention records
> and objects which is what I had mentioned earlier already.
>
> Yes I see this on https://freepascal.org/docs-html/ref/refse47.html. Why
> isn't this supported? I guess as part of this proposal we need to implement
> this feature as well?  I'm not familiar with this area of the language so
> I'm not sure what this entails.
>

Simply because no one has come around to implement it yet. The class type
case is more complicated than the interface case. (Same would be true for
record and objects)
So, yes, we'll need to implement this first which would finally bring FPC
up to Delphi compatibility regarding interface delegation.


> >
> >> It's a strange syntax compared to anything else we allow in classes and
> the boiler plate is really adding up now. "procedure Draw" is going to be
> in 4 lines now!
> >>
> >> It would be nicer if they made this into one line so we don't have yet
> another set of duplicate method signatures, i.e.:
> >>
> >>   procedure Draw as ICircle.Draw;
> >
> > I can't shake the feeling that all you complain about is writing even a
> little bit too much. Pascal is *not* about using as less code as possible,
> but to be as correct as possible and the syntax of interface delegation
> allows exactly that.
>
> Being too verbose is clunky in my opinion. That method resolution syntax
> is just kind of an odd addition for classes to my eyes. "procedure
> Type.Name = Name;" doesn't have any precedence inside classes/records so it
> stands out.
>

Again, the syntax is much more powerful than what you suggested. Also it's
the existing syntax and not something new. Not to mention that it only
needs to be used if you need to implement a method yourself.
Iff(!) we find out down the line once we have the basic functionality
working, that people are struggling with this, we can still think about
improving something, but for now I'd prefer to add as less new syntaxes as
possible (especially if a syntax that does provide this exact functionality
*does* exist already, no matter if it's too verbose for some).

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210217/72fe74c4/attachment.htm>


More information about the fpc-pascal mailing list