If it’s a large matrix, this can cause a lot of overhead. More so than constructing a
var for each on the autodiff stack. Just try profiling for different size matrices even without autodiff. At a certain point, you’re going to blow cache and it’s going to really slow down.
A headache for whom? If it makes the code a lot easier to read, that may be worth it. This is related to Sean’s comment, which gets at the key to maintainability (and to a large degree, testability):
So if an abstraction makes things easier to test and isolates some difficult code and makes the rest easier to read, it can be worth it. Sean gets at that here:
The challenge here is that the developer of a piece of code can see its structure much more clearly than someone else coming in to look at it, but the code needs to be written for that next person.
Sean—is this something we can retrofit later?
This is one of the keys to the readabilty issue. It’s much easier to read the name of a function and look at its arguments than to try to infer that from a block of code. This is precisely one of those places where it’s much harder for the reader of the code to get a picture of what’s going on than the author.