Open Epitrochoid opened 3 years ago
Yeah that's a good start!
To generalize it so it can be used anywhere I guess you would define a value()
parser that resolves variables into primitive types. Another approach would be to parse everything first and then evaluate variables to their underlying values, ie. a 2-step process.
Actually that would only work for "static" variables ... variables that change over the course of the program will need to be treated differently, and for doing something like selection/move &grid.x
the variable needs to be preserved and looked up only at the time when the command is executed.
Implemented a quick spike of one of the ideas from issue #120. This is a pretty limited example since it only supports using a setting as a variable in a
Set
call.set grid/color = &background
or similar works with these changes.Is this a direction worth pursuing? To be useful for #120 it would in the very least need to cover referencing a setting's value in any command (allowing selection movement to be based on grid size). Adding code to each and every command doesn't seem tenable, but I'm fairly sure that mapping over the
cmd
argument infn command
(session.rs) and resolving anyValue::var
s would be doable.Additionally I didn't tackle tuple destructuring support here. I'm thinking the easiest solution would be to allow tuple values to access by index as
&grid/spacing.0
or possibly&grid/spacing.first
.