Guest Posted February 17, 2021 for sue! at end, HE is always contested... hug Share this post Link to post
David Heffernan 2345 Posted February 17, 2021 (edited) 1 hour ago, emailx45 said: hey "genius" if dont like it, dont use! Why would anybody use code that does nothing? You call a procedure passing parameters by value. Then that procedure modifies those parameters. You've basically done this: procedure Foo(Value: Integer); begin Value := 0; end; I don't think it takes a genius to see that this is pointless. Furthermore, were your function able to do what you think it can, it's still useless. Who the heck is going to call a procedure passing a list of variables, to have that procedure set them to zero? You'll just set them to zero at the call site using the assignment operator. You really think people are going to write: prcInitItPlease([lMyVarLocalThiProc, lMyOtherVarLocal]); (which does not and cannot work as noted above) rather than lMyVarLocalThiProc := 0; lMyOtherVarLocal := 0; Honestly, this thread is mind boggling! Edited February 17, 2021 by David Heffernan 2 Share this post Link to post
balabuev 102 Posted February 17, 2021 7 hours ago, Kas Ob. said: with optimization enabled not all locals are stored on the stack, some are just reserved CPU registers What is more, in some cases compiler can use the same register for several local variables. So, "all" local variables do not even exist at the beginning of procedure. 1 Share this post Link to post
David Heffernan 2345 Posted February 17, 2021 (edited) 33 minutes ago, emailx45 said: JUST THE VALUE It's passed by value in your procedure. The caller can't see the change. Also, the original concept would be something that would zeroise local vars without them needing to be listed. Your code fails in every possible way to meet the requirements. And indeed any user defined function would fail, because the asker wants to have the compiler do it. Edited February 17, 2021 by David Heffernan 2 Share this post Link to post
Attila Kovacs 629 Posted February 17, 2021 We're approaching levels unseen. 2 1 Share this post Link to post
shineworld 73 Posted February 18, 2021 I'm used to placing a procedure Init in any record so is simple to set defaults according to data types of records. PCompileArguments = ^TCompileArguments; TCompileArguments = record Mode: TCompileMode; Code: string; X: Extended; Y: Extended; Z: Extended; A: Extended; B: Extended; C: Extended; ToolPathMode: TToolPathMode; Line: Cardinal; FirstCmdId: Cardinal; LastLine: Cardinal; LastCmdId: Cardinal; procedure Assign(Source: PCompileArguments); overload; procedure Assign(Source: TCompileArguments); overload; procedure Init; overload; procedure Init(Mode: TCompileMode; const Code: string; X, Y, Z, A, B, C: Extended; ToolPathMode: TToolPathMode; Line, FirstCmdId, LastLine, LastCmdId: Cardinal); overload; function LoadFromMemento(Memento: IMemento): Boolean; function SaveToMemento(Memento: IMemento): Boolean; end; Share this post Link to post