[Pas2js] My 1st type helper

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Mar 3 13:07:05 CET 2019


On Sun, 3 Mar 2019 11:52:07 +0100
Sven Barth via Pas2js <pas2js at lists.freepascal.org> wrote:

>[...]
> > No, helpers are active even inside the helped class itself.  
> Though there the search order is slightly different, if I remember 
> correctly (especially when inherited helpers and/or the parents of
> the extended class are involved).

Helpers have some severe inconsistencies, but this case is not one of
them.
The rule is simple:
First the active helper, then its ancestors, 
then if multihelpers the next helper and its ancestors,
then the helper-for type.
Then the ancestor (may have helpers too).

The inconsistent rules are the "inherited;" and "inherited name;"
expressions.
And there is no way to call the inherited method of an ancestor helper.
Other inconsistencies are aProperty.helpercall, and ignoring visibility
of nested helpers. These break OOP rules, thus many considers helpers
a hack. I wish there is a $mode where these inconsistencies are fixed.
In pas2js it would easy to do, but I guess it is more difficult in fpc.
For Delphi I have less hope, they even allow 'virtual' methods, which
makes no sense to me, in fact they crash, which makes sense to me.

Btw, pas2js trunk now supports type helper for classtype/interfacetype.

Mattias


More information about the Pas2js mailing list