the way that "parameters are passed" between a program and a subroutine in Mach is to simply set global variables. This is Ok, I guess, but requires a tremendous amount of discipline on the part of the programmer,
Yes. That is correct.
At one stage in the programming world, quite some years ago, there was tremendous management enthusiasm for ego-less and programmer-free programming. The underlying reason for this was that management objected to paying for highly skilled programmers and wanted the whole thing dumbed down so they could employ cheap high school graduates - and still get reliable secure SW. It did not happen.
But we still have this idea floating around that programining should not require skill. Tell that to the InfoSec industry, NASA or aerospace companies. Or to companies trying to create Autonomous Vehicles. Ha! Yes, skill is required to convert human ideas into machine language! If you don't have that skill, either learn it or resort to poking buttons on a Fanuc control panel. No apologies.
I have already addressed your concerns about stomping on local variables. I DEFINE my variables at the start of the program, not just with a value (like 25.0 mm), but also in English, so I know what that variable is about. And I reserve some variables for local use within a subroutine. I assume that anything which had been stored in one of those variables in a different SR can be over-written in this SR. Yes, programing discipline is required. Without it you have machine crashes.
I would never write something as obscure as G0 G54 G90 X0. Y0. That is an abuse of the programmer's mind. I would write, with the comments shown
G90 % absolute distance mode
G54 % workspace 1
G0 X0 Y0 % go to ...
That way, when I come back to this program 4 weeks later, I can see at a glance what the program is doing - by reading the comments.
Which is how I imagine you passing data from you main program to your subroutine.
I can see how you get here, but basically, No. I do not define dimensional parameters that way, just before calling a subroutine. Parts dimensions are defined at the start of the program.
That said, I do often define some control parameters just before calling a subroutine:
#1= ... % Z travel for milling downwards
#2=fup[#1/#20] % N passes downwards, each no more than #20 in depth
#3=[#1/#2] % actual dZ for each pass, less than #20
m98 p100 L#2 % machine downwards for N cycles
Note that parameter #3 will be used inside the SR o100 to decrement the current Z each time.
Is it all a matter of personal programming style? Yep.
My 2c
Cheers
Roger