I don't see what data frames have to do with this. In order to get your
data.frame solution to work, the data.frame had to be made global.
The problem here is how scoping works, and what gets stored in the
result of a call to a fitting function.
One solution that would work without putting the function's locals on
the search list is to introduce the idea of pointers to S. The result
of a fit wouldn't just contain the names of the variables involved, it
would also contain pointers to the actual instances that were involved
in the fit. I don't know if this would break more code or less than
modifying the search list, but I'd suspect less. It must be fairly
unusual to slip new data into the search list ahead of the original data
used for a fit, and if you didn't do that, you should get identical
results. But maybe introducing pointers would break other things.
Duncan Murdoch