Recent

Author Topic: Class helpers  (Read 1318 times)

jamie

  • Hero Member
  • *****
  • Posts: 1765
Re: Class helpers
« Reply #15 on: May 13, 2019, 11:01:18 pm »
Yeah well I am glad you did that because I put it to heavy use! :)

BeniBela

  • Hero Member
  • *****
  • Posts: 678
    • homepage
Re: Class helpers
« Reply #16 on: May 14, 2019, 12:46:38 am »
I do not understand why there are so many different helpers

Why not call them all "type helper"  ?

jamie

  • Hero Member
  • *****
  • Posts: 1765
Re: Class helpers
« Reply #17 on: May 14, 2019, 12:54:14 am »
I suppose the compiler could auto detect this via the object that is supplied so one don't need to specify which of the
types it wants to help.

 But what I was getting more to was the inherited feature to add on existing helpers.


furious programming

  • Sr. Member
  • ****
  • Posts: 354
  • I click a little.
Re: Class helpers
« Reply #18 on: May 14, 2019, 02:04:13 am »
Why not call them all "type helper"  ?

Hmm…

Code: Pascal  [Select]
  1. type
  2.   TFoo = class(TBar) // or any other type
  3.   {..}
  4.   end;
  5.  
  6. type
  7.   // instead of: TFooHelper = class helper for TFoo
  8.   TFooHelper = helper(TFoo)
  9.   {..}
  10.   end;
  11.  
  12. type
  13.   // instead of: TFooHelper2 = class helper(TFooHelper) for TFoo
  14.   TFooHelper2 = helper(TFooHelper)
  15.   // or
  16.   TFooHelper2 = helper(TFoo, TFooHelper)
  17.   {..}
  18.   end;

This should be enough. 8)
« Last Edit: May 14, 2019, 02:09:39 am by furious programming »
Lazarus 2.0.4 with FPC 3.0.4, Windows XP (all 32-bit)

PascalDragon

  • Hero Member
  • *****
  • Posts: 515
  • Compiler Developer
Re: Class helpers
« Reply #19 on: May 14, 2019, 09:07:41 am »
I do not understand why there are so many different helpers

Why not call them all "type helper"  ?
Because it was Delphi that introduced class helper and record helper. True, it was me that introduced type helper for primitive types, but with FPC 3.2.0 and newer it's possible to use type helper with classes and records as well, so for me type helper is the definite syntax for helper types (though the other two will be available no matter what).
Code: Pascal  [Select]
  1. type
  2.   TFoo = class(TBar) // or any other type
  3.   {..}
  4.   end;
  5.  
  6. type
  7.   // instead of: TFooHelper = class helper for TFoo
  8.   TFooHelper = helper(TFoo)
  9.   {..}
  10.   end;
  11.  
  12. type
  13.   // instead of: TFooHelper2 = class helper(TFooHelper) for TFoo
  14.   TFooHelper2 = helper(TFooHelper)
  15.   // or
  16.   TFooHelper2 = helper(TFoo, TFooHelper)
  17.   {..}
  18.   end;

This should be enough. 8)
True, that would be enough, but we'd need to support the other syntax anyway due to Delphi compatibility. The type helper syntax on the other hand is a close enough extension.