Sign in Join

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

Mailing lists / fpc-pascal / 2018-10

Default properties first draft

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Ryan Joseph

I finally finished what I think is first draft of default properties. Since it already took me so much time to just get the basics of the compiler figured out I thought I’d post this commit from GitHub and ask if I did anything seriously wrong or stupid. There are multiple ways I could approach this problem but I may have not achieved it a proper way considering the architecture of the compiler, which I admittedly don’t understand well.

How should I present for consideration at this stage? If anyone on the compiler team can look at the commit to tell me anything that would be helpful, or let me know if you need this in some other form that you could actually compile (I understand the compiler uses svn but I only know git). I have some demos of the basics mostly working but I have questions/problems I wasn’t able to solve on my own.

https://github.com/genericptr/freepascal/commit/e2992620e2e85d1100f60d13472571b8ebbf0bac

Here’s an example test in case people forgot what this was about.

======================================================================

program default_property_test_16;
uses
	fgl;
type
generic TAuto<T> = record
    m_object: T;
    property obj: T read m_object; default;
    class operator Initialize(var a: TAuto);
    class operator Finalize(var a: TAuto);
  end;
type
  TObjectAuto = specialize TAuto<TObject>;
  TStringList = specialize TFPGList<String>;
  TStringListAuto = specialize TAuto<TStringList>;
class operator TAuto.Initialize(var a: TAuto);
begin
  a.m_object := T.Create;
end;
class operator TAuto.Finalize(var a: TAuto);
begin
  a.m_object.Free;
end;
var
	list: TStringListAuto;
	str: string;
	i: integer;
begin
	list.Add('foo');
	list.Add('bar');
	for str in list do
		writeln(str);
	for i := 0 to list.count - 1 do
		writeln(list[i]);
end.

Regards,
Ryan Joseph

Reply by email

Ben Grasset
to Ryan Joseph

AFAIK you need to submit a ".patch" file with your changes against the most recent trunk revision to the bugtracker (with the category set to "patch", obviously.) I doubt it'll get considered seriously or looked at at all otherwise. For what it's worth, I did do a checkout of your branch and then a merge to get everything fully up to date, and when I went to do a full-tree build (compiler, RTL, everything) it raised a nonsensical error in the FCL-XML package in the "dom-html.pp" file, complaining that a call to GetItem for one of the list classes there didn't have enough parameters (which is not true.)

That function was being read from through a property, so it seems like you may possibly have broken something somewhere.

PM Ryan Joseph wrote 68 lines
I finally finished what I think is first draft of default properties. Since it already took me so much time to just get the basics of the compiler figured out I thought I’d post this commit from GitHub and ask if I did anything seriously wrong or stupid. There are multiple ways I could approach this problem but I may have not achieved it a proper way considering the architecture of the compiler, which I admittedly don’t understand well. How should I present for consideration at this stage? If anyone on the compiler team can look at the commit to tell me anything that would be helpful, or let me know if you need this in some other form that you could actually compile (I understand the compiler uses svn but I only know git). I have some demos of the basics mostly working but I have questions/problems I wasn’t able to solve on my own. https://github.com/genericptr/freepascal/commit/e2992620e2e85d1100f60d13472571b8ebbf0bac Here’s an example test in case people forgot what this was about. ====================================================================== program default_property_test_16; uses fgl; type generic TAuto<T> = record m_object: T; property obj: T read m_object; default; class operator Initialize(var a: TAuto); class operator Finalize(var a: TAuto); end; type TObjectAuto = specialize TAuto<TObject>; TStringList = specialize TFPGList<String>; TStringListAuto = specialize TAuto<TStringList>; class operator TAuto.Initialize(var a: TAuto); begin a.m_object := T.Create; end; class operator TAuto.Finalize(var a: TAuto); begin a.m_object.Free; end; var list: TStringListAuto; str: string; i: integer; begin list.Add('foo'); list.Add('bar'); for str in list do writeln(str); for i := 0 to list.count - 1 do writeln(list[i]); end. Regards, Ryan Joseph _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Ryan Joseph
to Ben Grasset

Thanks Ben. I didn't want to submit a patch file yet (not that I know how anyways) because I don’t think it’s complete and perhaps it’s not even on the right track in terms of implementation. The compiler team seems busy now anyways so I guess this will just have to wait.

I didn’t do any extensive tests yet on big projects like the FPC RTL but there’s probably a bug I didn’t catch with default [] properties calling into my code. You should be able to compile single units though and test the syntax.

Show quoted text 5 lines
On Oct 21, 2018, at 4:37 AM, Ben Grasset wrote: AFAIK you need to submit a ".patch" file with your changes against the most recent trunk revision to the bugtracker (with the category set to "patch", obviously.) I doubt it'll get considered seriously or looked at at all otherwise. For what it's worth, I did do a checkout of your branch and then a merge to get everything fully up to date, and when I went to do a full-tree build (compiler, RTL, everything) it raised a nonsensical error in the FCL-XML package in the "dom-html.pp" file, complaining that a call to GetItem for one of the list classes there didn't have enough parameters (which is not true.) That function was being read from through a property, so it seems like you may possibly have broken something somewhere.

Regards,
Ryan Joseph

Reply by email

Ryan Joseph
to Ryan Joseph

I just fixed the bug you mentioned ([] default properties getting into my code paths) so feel free to test again.

https://github.com/genericptr/freepascal/tree/defaultprops

I also temporarily added some test units so you can see how far I’ve gotten testing them.

https://github.com/genericptr/freepascal/tree/defaultprops/tests/defaultprops

On Oct 21, 2018, at 9:51 AM, Ryan Joseph wrote: I didn’t do any extensive tests yet on big projects like the FPC RTL but there’s probably a bug I didn’t catch with default [] properties calling into my code. You should be able to compile single units though and test the syntax.

Regards,
Ryan Joseph

Reply by email