Passing parameters by name lazarus / 21-General ---------------------------------------------------------------------- MarkMLl · 2021-01-19 22:19 Can somebody provide an update on defining records using named fields at runtime? I believe that this was supposed to be implemented at some point but I've just been idly experimenting and it doesn't (yet) work. Or I'm doing something stupid, which is of course likely :-) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program test; type  opType= record            name: string[255];            priority: integer          end; const  add: opType= (name: '+'; priority: 5);   // OK//  sub: opType= (priority: 5; name: '-'); // Compile-time error (as documented)  mul: opType= (name: '*');              // Compile-time warning  procedure defineOp(const op: opType); beginend { defineOp } ;  begin  defineOp(add);                 // OK  defineOp(name: '+'; priority: 5) // Compile-time errorend.  MarkMLl ---------------------------------------------------------------------- Josh · 2021-01-19 23:17 Code: [Select]mul: opType= (name: '*');if you add your priority param Code: [Select]mul: opType= (name: '*'; priority: 2); ---------------------------------------------------------------------- PascalDragon · 2021-01-20 07:19 Quote from: MarkMLl on January 19, 2021, 11:19:29 pmCan somebody provide an update on defining records using named fields at runtime? I believe that this was supposed to be implemented at some point but I've just been idly experimenting and it doesn't (yet) work. This is not supported and there are no plans to do so. ---------------------------------------------------------------------- MarkMLl · 2021-01-20 09:28 Quote from: josh on January 20, 2021, 12:17:42 am Code: [Select]mul: opType= (name: '*');if you add your priority param Code: [Select]mul: opType= (name: '*'; priority: 2); Yes. But the documentation was unclear whether a missing field was a compilation or runtime error. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2021-01-20 09:33 Quote from: PascalDragon on January 20, 2021, 08:19:17 amQuote from: MarkMLl on January 19, 2021, 11:19:29 pmCan somebody provide an update on defining records using named fields at runtime? I believe that this was supposed to be implemented at some point but I've just been idly experimenting and it doesn't (yet) work. This is not supported and there are no plans to do so. OK. My mistake, I thought you'd said in the past that this sort of tuple would eventually be supported. Unfortunate decision IMO, since I've had situations in the past where changing the number of parameters of a function with a final optional parameter resulted in a bug which was very difficult to pin down, and being able to pass parameters by name rather than position would avoid that. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2021-01-20 12:30 Quote from: MarkMLl on January 20, 2021, 10:33:01 amQuote from: PascalDragon on January 20, 2021, 08:19:17 amQuote from: MarkMLl on January 19, 2021, 11:19:29 pmCan somebody provide an update on defining records using named fields at runtime? I believe that this was supposed to be implemented at some point but I've just been idly experimenting and it doesn't (yet) work. This is not supported and there are no plans to do so. OK. My mistake, I thought you'd said in the past that this sort of tuple would eventually be supported. There was the suggestion by Ryan Joseph to add support for record constructors that are similar to the variable/constant initializations. And maybe I said that this might be investigated. ---------------------------------------------------------------------- MarkMLl · 2021-01-20 12:35 Quote from: PascalDragon on January 20, 2021, 01:30:03 pmThere was the suggestion by Ryan Joseph to add support for record constructors that are similar to the variable/constant initializations. And maybe I said that this might be investigated. Maybe. This might have been about three years ago. MarkMLl