Re: [fpc-pascal] Default record const values

2018-11-28 Thread Ryan Joseph
> On Nov 29, 2018, at 2:27 AM, Benjamin Rosseaux wrote: > > TTestHelper = record helper for TTest > public > const Default: TTest = (a: 1; b: 2); > end; I didn’t even know you could add consts to record helpers. That’s good to know, thanks. Multi scoped helpers will make this a safe

Re: [fpc-pascal] Default record const values

2018-11-28 Thread Benjamin Rosseaux
I'm using this solution myself for the vector and matrix data types at https://github.com/BeRo1985/pasvulkan/blob/master/src/PasVulkan.Math.pas https://github.com/BeRo1985/pasvulkan/blob/master/src/PasVulkan.Math.TpvVector2.Swizzle.Definitions.inc

Re: [fpc-pascal] Default record const values

2018-11-28 Thread Sven Barth via fpc-pascal
Am 28.11.2018 um 20:27 schrieb Benjamin Rosseaux: program Test123; {$ifdef fpc}   {$mode delphi} {$endif} type   TTest = record   public     a: LongInt;     b: LongInt;   end;   TTestHelper = record helper for TTest   public     const Default: TTest = (a: 1; b: 2);   end; var   Test: TTest;

Re: [fpc-pascal] Default record const values

2018-11-28 Thread Benjamin Rosseaux
program Test123; {$ifdef fpc} {$mode delphi} {$endif} type TTest = record public a: LongInt; b: LongInt; end; TTestHelper = record helper for TTest public const Default: TTest = (a: 1; b: 2); end; var Test: TTest; begin Test := TTest.Default; end. On Sat, Nov 10,

Re: [fpc-pascal] Default record const values

2018-11-13 Thread Sven Barth via fpc-pascal
Am 14.11.2018 um 02:05 schrieb John Doe: On Mon, Nov 12, 2018 at 1:51 AM Sven Barth via fpc-pascal > wrote: The compiler now correctly rejects such declarations with a "Type is not completely defined error". Making this not work is a ridiculous

Re: [fpc-pascal] Default record const values

2018-11-13 Thread John Doe
On Mon, Nov 12, 2018 at 1:51 AM Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > The compiler now correctly rejects such declarations with a "Type is > not completely defined error". > Making this not work is a ridiculous removal of a feature for no logical reason that

Re: [fpc-pascal] Default record const values

2018-11-12 Thread Martok
Am 10.11.2018 um 12:17 schrieb Ryan Joseph: > This also fails. I personally find this case much more limiting. Another implication is that you can't build up consts from other record consts, such as: -- type TMyRecord = record a:

Re: [fpc-pascal] Default record const values

2018-11-11 Thread Sven Barth via fpc-pascal
Am Mo., 12. Nov. 2018, 02:56 hat Ryan Joseph geschrieben: > > > > On Nov 12, 2018, at 8:08 AM, Ryan Joseph > wrote: > > > > But this syntax worked if you assigned it within blocks. Why does it > need to be removed? Since I discovered it I was planning on using it > instead of class functions

Re: [fpc-pascal] Default record const values

2018-11-11 Thread Ryan Joseph
> On Nov 12, 2018, at 8:08 AM, Ryan Joseph wrote: > > But this syntax worked if you assigned it within blocks. Why does it need to > be removed? Since I discovered it I was planning on using it instead of class > functions with default values which require an implementation and are much >

Re: [fpc-pascal] Default record const values

2018-11-11 Thread Ryan Joseph
> On Nov 12, 2018, at 5:06 AM, Sven Barth via fpc-pascal > wrote: > > The compiler now correctly rejects such declarations with a "Type is not > completely defined error". But this syntax worked if you assigned it within blocks. Why does it need to be removed? Since I discovered it I was

Re: [fpc-pascal] Default record const values

2018-11-11 Thread Sven Barth via fpc-pascal
Am 10.11.2018 um 09:35 schrieb Ryan Joseph: Should’t this work? This would be a good way to set default record values but it doesn’t seem to be supported. type TMyRecord = record public a: integer; b: string;

Re: [fpc-pascal] Default record const values

2018-11-10 Thread Ben Grasset
On Sat, Nov 10, 2018 at 9:03 PM Ryan Joseph wrote: > Not sure how default fields in generics help here. I just thought it would > be nice if FPC supported this so we can init records at compile time > easier. I’d prefer default struct fields like C++ has but typed const > defaults would be an

Re: [fpc-pascal] Default record const values

2018-11-10 Thread Ryan Joseph
> On Nov 11, 2018, at 6:51 AM, Ben Grasset wrote: > > Personally I think the answer here is keep working on your new/alternate > implementation of default field functionality! It's a missing puzzle piece > for FPC generics in many ways. > Not sure how default fields in generics help here.

Re: [fpc-pascal] Default record const values

2018-11-10 Thread Ben Grasset
On Sat, Nov 10, 2018 at 4:06 AM Ryan Joseph wrote: > Should’t this work? This would be a good way to set default record values > but it doesn’t seem to be supported. Personally I think the answer here is keep working on your new/alternate implementation of default field functionality! It's a

Re: [fpc-pascal] Default record const values

2018-11-10 Thread Sven Barth via fpc-pascal
Am Sa., 10. Nov. 2018, 12:44 hat Ryan Joseph geschrieben: > Not quite understanding how that’s not entirely parsed by the time you > assign outside of the record. Even so I would expect it to copy what the > const was able to capture, fully parsed or not. > It's not entirely parsed by the time

Re: [fpc-pascal] Default record const values

2018-11-10 Thread Ryan Joseph
This also fails. type TMyRecord = record public a: integer; b: string; end; const TMyRecord_Default: TMyRecord = (a: 100; b: 'foo'); var r: TMyRecord = TMyRecord_Default; > On Nov 10, 2018, at 4:55

Re: [fpc-pascal] Default record const values

2018-11-10 Thread Ryan Joseph
Not quite understanding how that’s not entirely parsed by the time you assign outside of the record. Even so I would expect it to copy what the const was able to capture, fully parsed or not. Also, why does it work to do begin r := TMyRecord.default; in the main block? > On Nov 10, 2018,

Re: [fpc-pascal] Default record const values

2018-11-10 Thread Sven Barth via fpc-pascal
Am Sa., 10. Nov. 2018, 10:06 hat Ryan Joseph geschrieben: > Should’t this work? This would be a good way to set default record values > but it doesn’t seem to be supported. > TMyRecord is not yet completely parsed. There could be another field located behind the "default" constant. Thus using

[fpc-pascal] Default record const values

2018-11-10 Thread Ryan Joseph
Should’t this work? This would be a good way to set default record values but it doesn’t seem to be supported. type TMyRecord = record public a: integer; b: string; const default: