Recent

Author Topic: LGenerics: yet another generics collection  (Read 34544 times)

Okoba

  • Sr. Member
  • ****
  • Posts: 363
Re: Yet another generics collection
« Reply #90 on: March 09, 2022, 11:20:00 am »
Great job avk!
Just tested it and works fine.

AlexTP

  • Hero Member
  • *****
  • Posts: 1994
    • UVviewsoft
Re: Yet another generics collection
« Reply #91 on: March 09, 2022, 11:28:07 am »

avk

  • Hero Member
  • *****
  • Posts: 682
Re: LGenerics: yet another generics collection
« Reply #92 on: March 12, 2022, 06:54:37 pm »
Thanks, I also added a bit more about sortings and algorithms on graphs.

AlexTP

  • Hero Member
  • *****
  • Posts: 1994
    • UVviewsoft
Re: LGenerics: yet another generics collection
« Reply #93 on: March 12, 2022, 07:52:21 pm »
Wiki pic says:
"Cycles per element (lower is better)".
What is cycle?
Why not 'milliseconds'?

avk

  • Hero Member
  • *****
  • Posts: 682
Re: LGenerics: yet another generics collection
« Reply #94 on: March 13, 2022, 06:04:31 am »
The processor (core) cycle (clock cycle) is the interval between two pulses of the clock generator, the number of cycles per unit of operation can be considered a measure of performance.
The point is that the fastest algorithms process some test samples of the specified size in less than 1ms. I do not know how to measure such time intervals in Windows, whereas thanks to the presence of rdtscp instruction the number of cycles is easy to know.

440bx

  • Hero Member
  • *****
  • Posts: 3252
Re: LGenerics: yet another generics collection
« Reply #95 on: March 13, 2022, 09:27:52 am »
@avk,

I have to say... the more I look at your LGenerics collection of functions, the more I like it.  You really did a great job.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 SP1 64bit.

avk

  • Hero Member
  • *****
  • Posts: 682
Re: LGenerics: yet another generics collection
« Reply #96 on: April 14, 2022, 08:33:21 am »
Hi!
Recent news from LGenerics: added functionality (TJsonPatch class) to implement JSON Patch(RFC 6902);

JSON Patch is a JSON document format (media type is application/json-patch+json) for expressing a sequence of operations applied to a target JSON document;
it is always an array of objects, each representing a single operation, supported set of operations: ADD, REMOVE, REPLACE, MOVE, COPY, and TEST;
For example, for this document
Code: Text  [Select][+][-]
  1. {
  2.     "foo": [1, 3],
  3.     "boo": ["bar", "baz"]
  4. }
  5.  

applying this patch
Code: Text  [Select][+][-]
  1. [
  2.     {"op": "add", "path": "/foo/1", "value": "fizz"},
  3.     {"op": "replace", "path": "/boo/1", "value": "qux"},
  4.     {"op": "add", "path": "/ozz", "value": "zoo"}
  5. ]
  6.  

will have the following result:
Code: Text  [Select][+][-]
  1. {
  2.     "foo": [1, "fizz", 3],
  3.     "boo": ["bar", "qux"],
  4.     "ozz": "zoo"
  5. }
  6.  

The TJsonPatch class also contains a POC implementation of the Diff utility, which generates a patch by comparing source and target documents.
For example, for this source
Code: Text  [Select][+][-]
  1. {
  2.     "a": 1,
  3.     "b": null,
  4.     "c": ["test", "plop"]
  5. }
  6.  

and for this target
Code: Text  [Select][+][-]
  1. {
  2.     "a": 6,
  3.     "c": ["test", "flop"],
  4.     "d": "baz"
  5. }
  6.  

it will generate a patch like this:
Code: Text  [Select][+][-]
  1. [
  2.     {"op": "replace", "path": "/a", "value": 6},
  3.     {"op": "remove", "path": "/b"},
  4.     {"op": "replace", "path": "/c/1", "value": "flop"},
  5.     {"op": "add", "path": "/d", "value": "baz"}
  6. ]
  7.  

Happy coding!

AlexTP

  • Hero Member
  • *****
  • Posts: 1994
    • UVviewsoft
Re: LGenerics: yet another generics collection
« Reply #97 on: April 14, 2022, 08:56:50 am »
« Last Edit: April 14, 2022, 04:17:21 pm by AlexTP »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 10479
  • FPC developer.
Re: LGenerics: yet another generics collection
« Reply #98 on: April 14, 2022, 09:31:14 am »
Wiki pic says:
"Cycles per element (lower is better)".
What is cycle?
Why not 'milliseconds'?

Because milliseconds varies between two processors of the same kind but with different frequencies. Cycles is a measure independent of the clock rate.

avk

  • Hero Member
  • *****
  • Posts: 682
Re: LGenerics: yet another generics collection
« Reply #99 on: April 14, 2022, 02:47:44 pm »
@AlexTP, thanks. I edited the wiki page a bit, maybe you should fix the link.

avk

  • Hero Member
  • *****
  • Posts: 682
Re: LGenerics: yet another generics collection
« Reply #100 on: December 08, 2022, 03:40:54 pm »
Hi!
There is some news in LGenerics: added(in the first approximation) unit for handling CSV documents(lgCsvUtils), which seems noticeably faster than CSVDocument. The list of classes is quite usual: the CSV document itself, the reader and the writer.

Of the additional features - the ability to selectively load document fields(a set of fields is specified by using a boolean mask), which can speed up loading.
And as an experiment, it is also possible to load large documents in multi-threaded mode.The current implementation, however, is not entirely safe because it is based on an assumption that may not hold true.

Anyway, experimenting with the "stop_times.txt" file mentioned in this discussion on my old dual-core Windows machine gives these numbers("masked" means masking the first four fields):
Code: Text  [Select][+][-]
  1. TCsvDocument, load from file: 14181 ms
  2. TCsvDocument, save to file:   66441 ms
  3. TCsvDoc, load from file:       1201 ms
  4. TCsvDoc, save to file:          468 ms
  5. TCsvDoc, load from file(MT):    671 ms
  6. TCsvDoc, load file(masked):     842 ms
  7. TCsvDoc, load file(masked,MT):  452 ms
  8.  

Any comments and suggestions are highly welcomed.   

avk

  • Hero Member
  • *****
  • Posts: 682
Re: LGenerics: yet another generics collection
« Reply #101 on: December 24, 2022, 07:24:09 am »
Hi!
I would like to inform you that a unit has been added to LGenerics for exporting Pascal data structures to JSON format. The following types are currently supported (called PDOs for short):
  • numeric, boolean or string types, some limited support of variants;
  • enumerations(exported in string form as the name of the corresponding constant);
  • sets(exported as an array of its elements);
  • regular records, it is possible to register a list of field names or a custom serialization callback;
  • classes, using published properties or by registering a custom callback(TStrings and TCollection as a special case);
  • objects(only by registering a custom serialization callback);
  • static arrays of PDO(only one-dimensional, multidimensional arrays are written as one-dimensional);
  • dynamic arrays of PDO;
  • variant arrays(currently only one-dimensional);
For example, this code(taken from LGenerics/example/json/pdo_export)
Code: Pascal  [Select][+][-]
  1. program pdo2json;
  2.  
  3. {$MODE OBJFPC}{$H+}{$MODESWITCH ADVANCEDRECORDS}
  4. {$OPTIMIZATION NOORDERFIELDS}
  5.  
  6. uses
  7.   SysUtils, Variants, lgUtils, lgJson, lgPdo;
  8.  
  9. type
  10.   TPerson = record
  11.     Id,
  12.     Age: Integer;
  13.     FirstName,
  14.     LastName,
  15.     Phone: string;
  16.     class procedure WriteJson(r: Pointer; aWriter: TJsonStrWriter); static;
  17.     constructor Make(aId, aAge: Integer; const aName, aLast, aPhone: string);
  18.   end;
  19.  
  20.   TIntArray = array of Integer;
  21.  
  22.   TMember = record
  23.     MemberId: Integer;
  24.     Meta: Variant;
  25.     Person: TPerson;
  26.     RegisterDate: string;
  27.     Friends: TIntArray;
  28.     Groups: TStringArray;
  29.     constructor Make(
  30.       const p: TPerson; aId: Integer; const aMeta: Variant; const d: string; const f: TIntArray;
  31.       const g: TStringArray);
  32.   end;
  33.   TMemberList = array of TMember;
  34.  
  35.   TCommunity = record
  36.     Name,
  37.     Slogan: string;
  38.     GroupList: TStringArray;
  39.     MemberList: TMemberList;
  40.     constructor Make(const aName, aSlogan: string; const gl: TStringArray; const ml: TMemberList);
  41.   end;
  42.   TCommunityList = array of TCommunity;
  43.  
  44. class procedure TPerson.WriteJson(r: Pointer; aWriter: TJsonStrWriter);
  45. type
  46.   PPerson = ^TPerson;
  47. const
  48.   cId    = 'id';
  49.   cAge   = 'age';
  50.   cName  = 'firstName';
  51.   cLast  = 'lastName';
  52.   cPhone = 'phone';
  53. begin
  54.   with PPerson(r)^ do
  55.     aWriter
  56.       .BeginObject
  57.         .Add(cId, Id)
  58.         .Add(cAge, Age)
  59.         .Add(cName, FirstName)
  60.         .Add(cLast, LastName)
  61.         .Add(cPhone, Phone)
  62.       .EndObject;
  63. end;
  64.  
  65. constructor TPerson.Make(aId, aAge: Integer; const aName, aLast, aPhone: string);
  66. begin
  67.   Id := aId;
  68.   Age := aAge;
  69.   FirstName := aName;
  70.   LastName := aLast;
  71.   Phone := aPhone;
  72. end;
  73.  
  74. constructor TMember.Make(const p: TPerson; aId: Integer; const aMeta: Variant; const d: string;
  75.   const f: TIntArray; const g: TStringArray);
  76. begin
  77.   MemberId := aId;
  78.   Meta := aMeta;
  79.   Person := p;
  80.   RegisterDate := d;
  81.   Friends := f;
  82.   Groups := g;
  83. end;
  84.  
  85. constructor TCommunity.Make(const aName, aSlogan: string; const gl: TStringArray; const ml: TMemberList);
  86. begin
  87.   Name := aName;
  88.   Slogan := aSlogan;
  89.   GroupList := gl;
  90.   MemberList := ml;
  91. end;
  92.  
  93. var
  94.   ComList: array of TCommunity = nil;
  95.  
  96. procedure MakeList;
  97. begin
  98.   ComList := [
  99.     TCommunity.Make(
  100.       'Earthlings', 'The further, the more',
  101.       ['bead game', 'kitchen', 'fishing', 'beer', 'skates', 'cutting and sewing', 'choral singing'],
  102.       [
  103.         TMember.Make(
  104.           TPerson.Make(
  105.             42, 21, 'Walter', 'Reynolds', '(204) 537-5981'
  106.           ),
  107.           1, null, '2018-11-13', [7, 17], ['bead game', 'beer', 'skates', 'cutting and sewing']
  108.         ),
  109.         TMember.Make(
  110.           TPerson.Make(
  111.             11, 32, 'Leigh', 'Garza', '(686) 795-8242'
  112.           ),
  113.           7, VarArrayOf([42, pi]), '2020-01-10', [1, 17, 21], ['kitchen', 'fishing', 'cutting and sewing']
  114.         ),
  115.         TMember.Make(
  116.           TPerson.Make(
  117.             5, 19, 'Damon', 'Shelton', '1-404-576-3173'
  118.           ),
  119.           17, VarArrayOf(['none', 'some', null]), '2020-07-29', [1, 11, 21], ['bead game', 'kitchen', 'fishing']
  120.         ),
  121.         TMember.Make(
  122.           TPerson.Make(
  123.             3, 27, 'Nora', 'Potts', '(824) 554-0791'
  124.           ),
  125.           11, VarArrayOf(['meta', 1001]), '2019-03-21', [7, 17, 21], ['beer', 'skates', 'cutting and sewing']
  126.         ),
  127.         TMember.Make(
  128.           TPerson.Make(
  129.             24, 44, 'Shad', 'Campbell', '(874) 556-376'
  130.           ),
  131.           21, 42, '2021-05-20', [1, 7, 17, 11], ['fishing', 'beer', 'cutting and sewing']
  132.         )
  133.       ]
  134.     ),
  135.     TCommunity.Make(
  136.       'Rabbit breeders', 'Who is not with us is not with us',
  137.       ['dinosaur hunting', 'knitting', 'chess', 'car race', 'dancing'],
  138.       [
  139.         TMember.Make(
  140.             TPerson.Make(
  141.               5, 23, 'Mikayla', 'Ray', '1-565-598-5632'
  142.             ),
  143.             22, VarArrayOf(['first', null, 42]), '2018-02-23', [17, 71, 45], ['dinosaur hunting', 'knitting']
  144.         ),
  145.         TMember.Make(
  146.           TPerson.Make(
  147.             37, 35, 'Tyler', 'Moody', '(345) 727-5455'
  148.           ),
  149.           17, 1001, '2021-11-13', [45, 10, 33], ['chess', 'car race', 'dancing']
  150.         ),
  151.         TMember.Make(
  152.           TPerson.Make(
  153.             17, 54, 'Plato', 'Henson', '1-385-896-8851'
  154.           ),
  155.           71, VarArrayOf(['get','put',null]), '2020-12-11', [22, 17], ['knitting', 'chess', 'car race']
  156.         ),
  157.         TMember.Make(
  158.           TPerson.Make(
  159.             23, 19, 'Merrill', 'Joseph', '(634) 768-7274'
  160.           ),
  161.           45, null, '2022-01-15', [17, 71, 10], ['dinosaur hunting', 'chess', 'dancing']
  162.         ),
  163.         TMember.Make(
  164.           TPerson.Make(
  165.             12, 29, 'Jessica', 'Meyers', '(706) 844-0017'
  166.           ),
  167.           10, VarArrayOf(['stop','none']), '2017-04-30', [17, 71, 45], ['knitting', 'chess', 'car race', 'dancing']
  168.         ),
  169.         TMember.Make(
  170.           TPerson.Make(
  171.             7, 33, 'Boris', 'Norton', '(211) 688-1153'
  172.           ),
  173.           33, VarArrayOf([null, null]), '2019-08-07', [22, 17, 71], ['dinosaur hunting', 'knitting', 'chess', 'car race', 'dancing']
  174.         )
  175.       ]
  176.     )
  177.   ];
  178. end;
  179.  
  180. var
  181.   n: specialize TGAutoRef<TJsonNode>;
  182.   s: string;
  183. begin
  184.   RegisterRecordJsonProc(TypeInfo(TPerson), @TPerson.WriteJson);
  185.   RegisterRecordFields(TypeInfo(TMember), ['memberId', 'meta', 'person', 'registerDate', 'friends', 'groups']);
  186.   RegisterRecordFields(TypeInfo(TCommunity), ['name', 'slogan', 'groupList', 'memberList']);
  187.  
  188.   MakeList;
  189.  
  190.   s := specialize PdoToJson<TCommunityList>(ComList);
  191.  
  192.   if not n.Instance.Parse(s) then
  193.     WriteLn('Oops, something went wrong :(')
  194.   else
  195.     WriteLn(n.Instance.FormatJson([jfoEgyptBrace]));
  196. end.
  197.  

will produce nice JSON like this:
Code: Text  [Select][+][-]
  1. [
  2.     {
  3.         "name": "Earthlings",
  4.         "slogan": "The further, the more",
  5.         "groupList": [
  6.             "bead game",
  7.             "kitchen",
  8.             "fishing",
  9.             "beer",
  10.             "skates",
  11.             "cutting and sewing",
  12.             "choral singing"
  13.         ],
  14.         "memberList": [
  15.             {
  16.                 "memberId": 1,
  17.                 "meta": null,
  18.                 "person": {
  19.                     "id": 42,
  20.                     "age": 21,
  21.                     "firstName": "Walter",
  22.                     "lastName": "Reynolds",
  23.                     "phone": "(204) 537-5981"
  24.                 },
  25.                 "registerDate": "2018-11-13",
  26.                 "friends": [
  27.                     7,
  28.                     17
  29.                 ],
  30.                 "groups": [
  31.                     "bead game",
  32.                     "beer",
  33.                     "skates",
  34.                     "cutting and sewing"
  35.                 ]
  36.             }, {
  37.                 "memberId": 7,
  38.                 "meta": [
  39.                     42,
  40.                     3.141592653589793
  41.                 ],
  42.                 "person": {
  43.                     "id": 11,
  44.                     "age": 32,
  45.                     "firstName": "Leigh",
  46.                     "lastName": "Garza",
  47.                     "phone": "(686) 795-8242"
  48.                 },
  49.                 "registerDate": "2020-01-10",
  50.                 "friends": [
  51.                     1,
  52.                     17,
  53.                     21
  54.                 ],
  55.                 "groups": [
  56.                     "kitchen",
  57.                     "fishing",
  58.                     "cutting and sewing"
  59.                 ]
  60.             }, {
  61.                 "memberId": 17,
  62.                 "meta": [
  63.                     "none",
  64.                     "some",
  65.                     null
  66.                 ],
  67.                 "person": {
  68.                     "id": 5,
  69.                     "age": 19,
  70.                     "firstName": "Damon",
  71.                     "lastName": "Shelton",
  72.                     "phone": "1-404-576-3173"
  73.                 },
  74.                 "registerDate": "2020-07-29",
  75.                 "friends": [
  76.                     1,
  77.                     11,
  78.                     21
  79.                 ],
  80.                 "groups": [
  81.                     "bead game",
  82.                     "kitchen",
  83.                     "fishing"
  84.                 ]
  85.             }, {
  86.                 "memberId": 11,
  87.                 "meta": [
  88.                     "meta",
  89.                     1001
  90.                 ],
  91.                 "person": {
  92.                     "id": 3,
  93.                     "age": 27,
  94.                     "firstName": "Nora",
  95.                     "lastName": "Potts",
  96.                     "phone": "(824) 554-0791"
  97.                 },
  98.                 "registerDate": "2019-03-21",
  99.                 "friends": [
  100.                     7,
  101.                     17,
  102.                     21
  103.                 ],
  104.                 "groups": [
  105.                     "beer",
  106.                     "skates",
  107.                     "cutting and sewing"
  108.                 ]
  109.             }, {
  110.                 "memberId": 21,
  111.                 "meta": 42,
  112.                 "person": {
  113.                     "id": 24,
  114.                     "age": 44,
  115.                     "firstName": "Shad",
  116.                     "lastName": "Campbell",
  117.                     "phone": "(874) 556-376"
  118.                 },
  119.                 "registerDate": "2021-05-20",
  120.                 "friends": [
  121.                     1,
  122.                     7,
  123.                     17,
  124.                     11
  125.                 ],
  126.                 "groups": [
  127.                     "fishing",
  128.                     "beer",
  129.                     "cutting and sewing"
  130.                 ]
  131.             }
  132.         ]
  133.     }, {
  134.         "name": "Rabbit breeders",
  135.         "slogan": "Who is not with us is not with us",
  136.         "groupList": [
  137.             "dinosaur hunting",
  138.             "knitting",
  139.             "chess",
  140.             "car race",
  141.             "dancing"
  142.         ],
  143.         "memberList": [
  144.             {
  145.                 "memberId": 22,
  146.                 "meta": [
  147.                     "first",
  148.                     null,
  149.                     42
  150.                 ],
  151.                 "person": {
  152.                     "id": 5,
  153.                     "age": 23,
  154.                     "firstName": "Mikayla",
  155.                     "lastName": "Ray",
  156.                     "phone": "1-565-598-5632"
  157.                 },
  158.                 "registerDate": "2018-02-23",
  159.                 "friends": [
  160.                     17,
  161.                     71,
  162.                     45
  163.                 ],
  164.                 "groups": [
  165.                     "dinosaur hunting",
  166.                     "knitting"
  167.                 ]
  168.             }, {
  169.                 "memberId": 17,
  170.                 "meta": 1001,
  171.                 "person": {
  172.                     "id": 37,
  173.                     "age": 35,
  174.                     "firstName": "Tyler",
  175.                     "lastName": "Moody",
  176.                     "phone": "(345) 727-5455"
  177.                 },
  178.                 "registerDate": "2021-11-13",
  179.                 "friends": [
  180.                     45,
  181.                     10,
  182.                     33
  183.                 ],
  184.                 "groups": [
  185.                     "chess",
  186.                     "car race",
  187.                     "dancing"
  188.                 ]
  189.             }, {
  190.                 "memberId": 71,
  191.                 "meta": [
  192.                     "get",
  193.                     "put",
  194.                     null
  195.                 ],
  196.                 "person": {
  197.                     "id": 17,
  198.                     "age": 54,
  199.                     "firstName": "Plato",
  200.                     "lastName": "Henson",
  201.                     "phone": "1-385-896-8851"
  202.                 },
  203.                 "registerDate": "2020-12-11",
  204.                 "friends": [
  205.                     22,
  206.                     17
  207.                 ],
  208.                 "groups": [
  209.                     "knitting",
  210.                     "chess",
  211.                     "car race"
  212.                 ]
  213.             }, {
  214.                 "memberId": 45,
  215.                 "meta": null,
  216.                 "person": {
  217.                     "id": 23,
  218.                     "age": 19,
  219.                     "firstName": "Merrill",
  220.                     "lastName": "Joseph",
  221.                     "phone": "(634) 768-7274"
  222.                 },
  223.                 "registerDate": "2022-01-15",
  224.                 "friends": [
  225.                     17,
  226.                     71,
  227.                     10
  228.                 ],
  229.                 "groups": [
  230.                     "dinosaur hunting",
  231.                     "chess",
  232.                     "dancing"
  233.                 ]
  234.             }, {
  235.                 "memberId": 10,
  236.                 "meta": [
  237.                     "stop",
  238.                     "none"
  239.                 ],
  240.                 "person": {
  241.                     "id": 12,
  242.                     "age": 29,
  243.                     "firstName": "Jessica",
  244.                     "lastName": "Meyers",
  245.                     "phone": "(706) 844-0017"
  246.                 },
  247.                 "registerDate": "2017-04-30",
  248.                 "friends": [
  249.                     17,
  250.                     71,
  251.                     45
  252.                 ],
  253.                 "groups": [
  254.                     "knitting",
  255.                     "chess",
  256.                     "car race",
  257.                     "dancing"
  258.                 ]
  259.             }, {
  260.                 "memberId": 33,
  261.                 "meta": [
  262.                     null,
  263.                     null
  264.                 ],
  265.                 "person": {
  266.                     "id": 7,
  267.                     "age": 33,
  268.                     "firstName": "Boris",
  269.                     "lastName": "Norton",
  270.                     "phone": "(211) 688-1153"
  271.                 },
  272.                 "registerDate": "2019-08-07",
  273.                 "friends": [
  274.                     22,
  275.                     17,
  276.                     71
  277.                 ],
  278.                 "groups": [
  279.                     "dinosaur hunting",
  280.                     "knitting",
  281.                     "chess",
  282.                     "car race",
  283.                     "dancing"
  284.                 ]
  285.             }
  286.         ]
  287.     }
  288. ]
  289.  

The performance should be noticeably better than in FpJsonRtti, but I would like to come back to that a little later.

Merry Christmas!

440bx

  • Hero Member
  • *****
  • Posts: 3252
Re: LGenerics: yet another generics collection
« Reply #102 on: December 24, 2022, 07:56:58 am »
Merry Christmas!
Thank you and Merry Christmas to you and everyone else as well.

Aside from that, I was compiling the "enumerable" example from your latest lgenerics and got the following errors:

Code: Text  [Select][+][-]
  1. Hint: (11030) Start of reading config file D:\Laz64trunk\fpc\bin\x86_64-win64\fpc.cfg
  2. Hint: (11031) End of reading config file D:\Laz64trunk\fpc\bin\x86_64-win64\fpc.cfg
  3. Free Pascal Compiler version 3.3.1-12125-g7da8c774be [2022/11/21] for x86_64
  4. Copyright (c) 1993-2022 by Florian Klaempfl and others
  5. (1002) Target OS: Win64 for x64
  6. (3104) Compiling lgenerics.pas
  7. (1008) 19 lines compiled, 4.8 sec
  8. (1022) 2 hint(s) issued
  9. Hint: (11030) Start of reading config file D:\Laz64trunk\fpc\bin\x86_64-win64\fpc.cfg
  10. Hint: (11031) End of reading config file D:\Laz64trunk\fpc\bin\x86_64-win64\fpc.cfg
  11. Free Pascal Compiler version 3.3.1-12125-g7da8c774be [2022/11/21] for x86_64
  12. Copyright (c) 1993-2022 by Florian Klaempfl and others
  13. (1002) Target OS: Win64 for x64
  14. (3104) Compiling simple_db.lpr
  15. (3104) Compiling main.pas
  16. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(93,26) Hint: (5024) Parameter "Sender" not used
  17. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(94,27) Hint: (5024) Parameter "Sender" not used
  18. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(95,30) Hint: (5024) Parameter "Sender" not used
  19. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(96,33) Hint: (5024) Parameter "Sender" not used
  20. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(97,28) Hint: (5024) Parameter "Sender" not used
  21. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(98,34) Hint: (5024) Parameter "Sender" not used
  22. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(99,39) Hint: (5024) Parameter "Sender" not used
  23. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(100,37) Hint: (5024) Parameter "Sender" not used
  24. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(101,27) Hint: (5024) Parameter "Sender" not used
  25. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(102,36) Hint: (5024) Parameter "Sender" not used
  26. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(103,40) Hint: (5024) Parameter "Sender" not used
  27. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(320,38) Error: (5038) Identifier idents no member "OrElseDefault"
  28. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(323,37) Error: (5038) Identifier idents no member "OrElseDefault"
  29. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(326,42) Error: (5038) Identifier idents no member "OrElseDefault"
  30. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(329,42) Error: (5038) Identifier idents no member "OrElseDefault"
  31. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(348,72) Error: (5038) Identifier idents no member "OrElseDefault"
  32. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(351,71) Error: (5038) Identifier idents no member "OrElseDefault"
  33. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(354,76) Error: (5038) Identifier idents no member "OrElseDefault"
  34. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(357,76) Error: (5038) Identifier idents no member "OrElseDefault"
  35. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(406,65) Error: (5038) Identifier idents no member "OrElseDefault"
  36. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(409,65) Error: (5038) Identifier idents no member "OrElseDefault"
  37. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(442,35) Error: (5038) Identifier idents no member "OrElseDefault"
  38. C:\Users\Private\Downloads\LGenerics-master\example\enumerable\main.pas(480) Fatal: (10026) There were 11 errors compiling module, stopping
  39. Fatal: (1018) Compilation aborted
  40. Error: D:\Laz64trunk\fpc\bin\x86_64-win64\ppcx64.exe returned an error exitcode
  41.  
The compiler is unhappy about "OrElseDefault". 

Suggestions/guidance as to how I could solve the problem would be most welcome :)

Thank you.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 SP1 64bit.

AlexTP

  • Hero Member
  • *****
  • Posts: 1994
    • UVviewsoft
Re: LGenerics: yet another generics collection
« Reply #103 on: December 24, 2022, 08:11:45 am »

avk

  • Hero Member
  • *****
  • Posts: 682
Re: LGenerics: yet another generics collection
« Reply #104 on: December 24, 2022, 08:35:36 am »
@440bx, thank you very much for discovering this sad fact. Some time ago I excluded the TGOptional.OrElseDefault() method and forgot to fix it in this example. Now fixed.

@AlexTP, thanks, but it seems a bit too long. I believe the example could have been removed.

 

TinyPortal © 2005-2018