Right now for any given primitive argument, one has to explicitly read in that argument's value from the modules array and assign it to some local variable, generally along with given a default:
if tag_exist( Modules[thisModuleIndex], "display") then display=uint(Modules[thisModuleIndex].display) else display=0
There are a lot of instances of that boilerplate code spread across the primitives.
I just realized it should be possible to eliminate all of them using the scope_varfetch low-level command to automatically set all those variables. It would work something like this:
__start_primitive already looks up the name of the calling function
Match that against the primitives config file's list of IDL functions. This will give you a list of all the arguments defined for that primitive, and their defaults, types, etc.
For each argument name in that use, obtain its value in the current recipe as above. Cast it to the appropriate type based on the Type attribute. Assign it to a local variable of the same name as the attribute name, using scope_varfetch. If that attribute is absent or blank, assign the default value.
Wish I'd thought of that a long time ago! At this point, would redoing it to work that way be worthwhile or just confusing? Note that even if we were to implement this automatic argument-to-variable setting, it wouldn't break any existing code; all the affected variables would just get set twice to the same values.
Right now for any given primitive argument, one has to explicitly read in that argument's value from the modules array and assign it to some local variable, generally along with given a default:
There are a lot of instances of that boilerplate code spread across the primitives.
I just realized it should be possible to eliminate all of them using the scope_varfetch low-level command to automatically set all those variables. It would work something like this:
Wish I'd thought of that a long time ago! At this point, would redoing it to work that way be worthwhile or just confusing? Note that even if we were to implement this automatic argument-to-variable setting, it wouldn't break any existing code; all the affected variables would just get set twice to the same values.