Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2015-07

Multiple Helpers for a type

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Ring

Hi Sven! (and perhaps others...)

A while ago (Aehm.. Feb 2013) you announced that type helpers are available for FreePascal. Which is great news ;-)

You also menitioned that there is a limitation,

"As with class and type helpers only one helper for a given type can be active"

but reading on, there was also hope ....

Future developments:
...
"Allow that multiple helpers are active for one type at a single time."

I now exactly hit that issue, I have a set of 'basic' typehelpers that I wanted to extend in a second unit, but unfortunately this does not work, the newly defined type-helpers do not allow me to access the functions defined in the 'basic' typehelper, so this approach is not possible....

Are those future development plans already reality and I did simply miss the correct modeswitch or is this still on the ToDo List?

If it's todo, are there already any plans on when this could get fixed?

Thank you,

Michael

Reply by email

Sven Barth
to Michael Ring
"Michael Ring" wrote
I now exactly hit that issue, I have a set of 'basic' typehelpers that I

wanted to extend in a second unit, but unfortunately this does not work, the newly defined type-helpers do not allow me to access the

functions defined in the 'basic' typehelper, so this approach is not

possible....

Would you please show code? Because at least in mode ObjFPC that should work and if not it's a bug.

Are those future development plans already reality and I did simply miss

the correct modeswitch or is this still on the ToDo List?

If it's todo, are there already any plans on when this could get fixed?

It's still on my ToDo list (the most complicated part being to define the order how methods are found). Currently I'm working on other topics though...

Regards,
Sven

Reply by email

Michael Ring
to Sven Barth

Here's a simplified example, it fails with a compiler error when compiling it with trunk:

test.pas(37,5) Error: Illegal qualifier
program test;
{$modeswitch objpas}
{$modeswitch advancedrecords}
{$modeswitch typehelpers}
type
   testlongWord = longWord;
var
   t : testlongWord;
type
   testlongWordHelper1 = record helper for testlongWord
     procedure setValue1(a : longWord);
     function getValue1 : longWord;
     property Value1 : longWord read getValue1 write setValue1;
   end;
type
   //testlongWordHelper2 = record helper (testlongWordHelper1) for
testlongWord
   testlongWordHelper2 = record helper for testlongWord
     procedure setValue2(a : longWord);
     function getValue2 : longWord;
     property Value2 : longWord read getValue2 write setValue2;
   end;
procedure testlongWordHelper1.setValue1(a : longWord);
begin
end;
function testlongWordHelper1.getValue1 : longWord;
begin
end;
procedure testlongWordHelper2.setValue2(a : longWord);
begin
end;
function testlongWordHelper2.getValue2 : longWord;
begin
end;
begin
   t.Value1 := 10;
   t.Value2 := 10;
end.
Sven Barth wrote 32 lines
Am 09.07.2015 14:38 schrieb "Michael Ring" < >: > > I now exactly hit that issue, I have a set of 'basic' typehelpers that I wanted to extend in a second unit, but unfortunately this does not work, the newly defined type-helpers do not allow me to access the > functions defined in the 'basic' typehelper, so this approach is not possible.... > Would you please show code? Because at least in mode ObjFPC that should work and if not it's a bug. > > Are those future development plans already reality and I did simply miss the correct modeswitch or is this still on the ToDo List? > > If it's todo, are there already any plans on when this could get fixed? It's still on my ToDo list (the most complicated part being to define the order how methods are found). Currently I'm working on other topics though... Regards, Sven _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Michael Ring
to Michael Ring

Please disregard last post, this demo actually works when I uncomment:

testlongWordHelper2 = record helper (testlongWordHelper1) for testlongWord

I will need to have another look if this example is too simple or I did something wrong in my 'real' code.

Michael

Michael Ring wrote 87 lines
Here's a simplified example, it fails with a compiler error when compiling it with trunk: test.pas(37,5) Error: Illegal qualifier program test; {$modeswitch objpas} {$modeswitch advancedrecords} {$modeswitch typehelpers} type testlongWord = longWord; var t : testlongWord; type testlongWordHelper1 = record helper for testlongWord procedure setValue1(a : longWord); function getValue1 : longWord; property Value1 : longWord read getValue1 write setValue1; end; type //testlongWordHelper2 = record helper (testlongWordHelper1) for testlongWord testlongWordHelper2 = record helper for testlongWord procedure setValue2(a : longWord); function getValue2 : longWord; property Value2 : longWord read getValue2 write setValue2; end; procedure testlongWordHelper1.setValue1(a : longWord); begin end; function testlongWordHelper1.getValue1 : longWord; begin end; procedure testlongWordHelper2.setValue2(a : longWord); begin end; function testlongWordHelper2.getValue2 : longWord; begin end; begin t.Value1 := 10; t.Value2 := 10; end. Am 09.07.15 um 17:17 schrieb Sven Barth: > > Am 09.07.2015 14:38 schrieb "Michael Ring" : > > > > I now exactly hit that issue, I have a set of 'basic' typehelpers > that I wanted to extend in a second unit, but unfortunately this does > not work, the newly defined type-helpers do not allow me to access the > > functions defined in the 'basic' typehelper, so this approach is > not possible.... > > > > Would you please show code? Because at least in mode ObjFPC that > should work and if not it's a bug. > > > > > Are those future development plans already reality and I did simply > miss the correct modeswitch or is this still on the ToDo List? > > > > If it's todo, are there already any plans on when this could get fixed? > > It's still on my ToDo list (the most complicated part being to define > the order how methods are found). Currently I'm working on other > topics though... > > Regards, > Sven > > > > _______________________________________________ > fpc-devel maillist > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email