I can not count the places in my macros where I have to use code like
if !exists(global.xyz)
global xyz = some complex expression
else
set var.xyz = SAME complex expression
This is caused by that HARD restriction that the "set" command EXPECTS the assigned variable to exist. I even may do a
if !exists(var.xyz)
var xyz = 0 ; or any fake value
set var.xyz = to the really wanted expression value
but I am not happy with this - for example the really set value type may not be numeric - but I know that this is an argument of esthetics.
My sugestion: (a) add another command - perhaps name it "assign" - that is a "set" but automatically will do a create of that variable before if neccessary.
Or (b) add a gcode like "Mxxx 0 / 1" which defines the behaviour of "set" on a global base.
Both options will not block to use the old coding but the will help to write cleaner and more secure macros.