[fpc-pascal] Generics: constructor restriction fail

silvioprog silvioprog at gmail.com
Thu Nov 13 16:01:47 CET 2014


On Tue, Nov 11, 2014 at 7:08 PM, Chriss Kalogeropoulos <
iz.iznogood at gmail.com> wrote:

> Hi all,
>
> I am not sure about the constructor case but I consider the FPC
> implementation of generics much more powerful than Delphi's assuming that
> Sven's comment actually works as expected.
> The fact that the method invocation is actually checked on specialization
> and not on declaration means that someone can call methods on the type
> parameter directly and not through some interface restriction which IMO is
> an ugly hack and cancels all possible optimizations for non virtual
> methods, since they much be called through the interface VMT.
> On Delphi XE5 I tried to use an interface constraint so that the compiler
> won't complaint about the methods and then I tried to call them through an
> object variable. This created a compiler internal error, even for class
> methods (declared in the interface but called directly from the type
> parameter). On FPC however it worked and IMO this is a good feature.
>
Recently I have installed Free Pascal 2.7.1 and I got very suprised about
the new implementations in generic structures. I'm even thinking about
rewriting some of my classes to reuse those resources to the fullest.

I'm excited about the Free Pascal 2.8. I want to teach an advanced course
of Object Pascal here in Brazil, and the Free Pascal will be the leading
actor at this story. =)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20141113/7cb3f6b8/attachment.html>


More information about the fpc-pascal mailing list