On 06.10.2013 01:46, Daniel Gaspary wrote:
On Sat, Oct 5, 2013 at 8:27 PM, Sven Barth <pascaldra...@googlemail.com> wrote:
At location A the helper is not yet declared, thus GetAnotherString uses the
GetString function of its own class. On location B the helper is already
declared and thus the implementation of GetAnotherString will pick up the
helper's GetString function instead.

I believed that the location that matters, in this case,  was only the
object instantiation (program/implementation body), because it was, in
both cases, after the helper declaration. A little weird.

No. Whenever you call a method (either inside a class using (implicit) Self or outside using a variable) the compiler checks whether a helper for that type is in scope and uses that if it is. It has nothing to do with object instantiation (that would be more for Traits/Mixins: http://en.wikipedia.org/wiki/Trait_%28computer_programming%29 ).

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to