Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#283 FreeBASIC does not allow to disable polymorphic behaviour when it's not needed!


By defining procedures as "Virtual", in many cases we want so to use the polymorphic behavior, but in some cases we would like to disable it to improve the execution time (in a loop for example where great execution speed is requested).

Let: an inheritance hierarchy "A<-B" ("Type B Extends A") and virtual members procedures "s()" in "A" And "B".
Let: an "A-type" pointer "p" to an object of "B" ("Dim As A Ptr p = New B").
- "p->s()" calls the procedure "B.s()" using dynamic binding at runtime by means of a double indirection (the polymorphism uses the member Vptr which points on the object's Vtable).
- In C++, "p->B::s()" calls the procedure "B.s()" using static binding at compile time (the compiler disables the polymorphism for this syntax).
In FreeBASIC, this kind of last syntax (disabling polymorphism) does not exist at present time.
(use the syntax "Cast(B Ptr, p)->s()" is inefficient because it uses always the same member VPTR but by inheritance)

The same principe as for the fix #663 http://sourceforge.net/p/fbc/bugs/663/ "Base.method() must not enable polymorphism (only inheritance)" could be applied (commit ade99e and commit 66ad5e, with a like-C++ syntax:
- Treat "instance.type::method()" as non-virtual call (to "type.method()").
- Disallow "instance.type::method()" calls to abstract methods, since they don't exist in the type.

Referring to forum at post http://www.freebasic.net/forum/viewtopic.php?p=192284#p192284