This works, but I'm mystified by the design choices in that function:
lst <- list(
a=structure(1:3, class="My_Class"),
b=structure(letters[1:3], class="My_Class")
)
env <- list2env(lst)
call <- as.call(append(list(fun), names(lst)))
eval(call, env)
To trick the function into working, you have to evaluate it in an environment where your list items are objects (this is what list2env
does, creates that environment).
The terrible thing about that function is that it looks up objects in parent.frame
based on their names, assuming that the ...
values are indeed names. I really don't understand why that function doesn't just do something like:
if(!all(vapply(list(...), class, "") == "My_Class")) stop(...)