Maybe a callable struct would be simpler here?
struct ActOnA{B}
buffer::B
end
# define what happens when we use an ActOnA object like a function
function (b::ActOnA)(A)
return acting_on_A_using_B_as_buffer(A, b.buffer)
end
act_on_A = ActOnA(similar(A)) # create buffer object
act_on_A(A) # call buffer object
Looks like the above poster beat me to this suggestion, but I’m still posting this for the snippet.