You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every modifier stage in our pipeline takes a single target as input and outputs a list of targets. The pipeline runner performs a flatmap at each stage: each input target is passed separately through the stage, yielding a list of targets, and then we concatenate these output lists corresponding to each input target, giving us a flat output list. That flat list then becomes the input for the next stage
This behaviour is usually what you want. However, there are situations in which it is helpful to maintain a deeper hierarchy. For example:
Notice how the first function has been cloned twice, with only the name changed. For each function, we'd like to bring the function name to every instance of aaa in the given function.
In this case, you might want to say something like "from every funk bring name to every instance air". Unfortunately, the "bring" command will complain that there are 3 sources, but 7 destinations, so they can't be zipped.
The solution
We create a modifier modifier that will cause its modifier not to get flatmapped. One possible approach that might work is to create a composite target that corresponds to a list of targets. Assuming we call this modifier modifier "layered". Then the above command would be "from every funk bring name to layered every instance air". Then "layered every instance" would return one composite target for each of its inputs, rather than returning a list of multiple targets for each input, that would then get flatmapped.
For now these composite targets could just throw an exception if you tried to use them for anything but constructing a destination (is this related to #1631?). When you construct a destination from a composite target, the constructChangeEdit function would just construct an edit that applies the change to all of the constituent targets. Alternately, if for some reason that doesn't work, we could make "bring" aware of this kind of destination, and it could handle the situation in its broadcasting code, where it's basically a broadcast from 1 to 2 dimensions, rather than today's 0 to 1 dimension (scalar to list).
Discussion points
Spoken form: "layered"? An alternative is "deep", but I was imagining that "deep every" would be a version of "every" that includes nested scopes
What term should we use when discussing modifier modifiers?
The text was updated successfully, but these errors were encountered:
Additional example (simplified a little from discussion on discord, in the previous example there was "north" on more things):
Goal: bring forth word of the function name to every instance of the second word of the doc string within the respective function
deffps_compass_go_north_relative():
"""Go north relative to current position"""globalcompass_offset, compass_anchordelta=compass_anchor-compass_offsetwin32api.mouse_event(win32con.MOUSEEVENTF_MOVE, delta, 0)
compass_offset=0set_last_action("compass_north")
deffps_compass_go_west_relative():
"""Go north relative to current position"""globalcompass_offsetx360=settings.get("user.fps_calibrate_x_360")
dx=-int(x360/4)
compass_offset+=dxwin32api.mouse_event(win32con.MOUSEEVENTF_MOVE, dx, 0)
set_last_action("compass_north")
deffps_compass_go_east_relative():
"""Go north relative to current position"""globalcompass_offsetx360=settings.get("user.fps_calibrate_x_360")
dx=int(x360/4)
compass_offset+=dxwin32api.mouse_event(win32con.MOUSEEVENTF_MOVE, dx, 0)
set_last_action("compass_north")
The problem
Every modifier stage in our pipeline takes a single target as input and outputs a list of targets. The pipeline runner performs a flatmap at each stage: each input target is passed separately through the stage, yielding a list of targets, and then we concatenate these output lists corresponding to each input target, giving us a flat output list. That flat list then becomes the input for the next stage
This behaviour is usually what you want. However, there are situations in which it is helpful to maintain a deeper hierarchy. For example:
Notice how the first function has been cloned twice, with only the name changed. For each function, we'd like to bring the function name to every instance of
aaa
in the given function.In this case, you might want to say something like
"from every funk bring name to every instance air"
. Unfortunately, the"bring"
command will complain that there are 3 sources, but 7 destinations, so they can't be zipped.The solution
We create a modifier modifier that will cause its modifier not to get flatmapped. One possible approach that might work is to create a composite target that corresponds to a list of targets. Assuming we call this modifier modifier
"layered"
. Then the above command would be"from every funk bring name to layered every instance air"
. Then"layered every instance"
would return one composite target for each of its inputs, rather than returning a list of multiple targets for each input, that would then get flatmapped.For now these composite targets could just throw an exception if you tried to use them for anything but constructing a destination (is this related to #1631?). When you construct a destination from a composite target, the
constructChangeEdit
function would just construct an edit that applies the change to all of the constituent targets. Alternately, if for some reason that doesn't work, we could make"bring"
aware of this kind of destination, and it could handle the situation in its broadcasting code, where it's basically a broadcast from 1 to 2 dimensions, rather than today's 0 to 1 dimension (scalar to list).Discussion points
"layered"
? An alternative is"deep"
, but I was imagining that"deep every"
would be a version of "every" that includes nested scopesThe text was updated successfully, but these errors were encountered: