At times it's useful, even within a module, to keep objects cleanly-organized with each other in lists. modules doesn't seem to like when we try to export an object that's stored in a list, however. (Though it does just fine at exporting the entire list.) Here's an example module.R file:
my_exports <- list()
my_exports$f1 <- function() "f1"
my_exports$f2 <- function() "f2"
modules::export(f1 = my_exports$f1, f2 = my_exports$f2) ## this errors
The above example uses explicit export naming, which is brought up as a separate issue here (#19).
It could also be nice to simply export all objects in a list, as I naïvely tried when experimenting with modules, e.g. the export call in the example above could be imagined like so:
do.call(modules::export, my_exports)
... i.e. where my_exports in the example is a named list of objects to export. I realize this introduces the error-handling behavior of 'what to do if there are unnamed list elements' ... I'd propose failing-fast in that case.
Perhaps a separate export wrapper function entirely that necessitates named elements? (Or even an option, like .require_name = <TRUE/FALSE> that forces naming behavior?)
At times it's useful, even within a module, to keep objects cleanly-organized with each other in lists.
modulesdoesn't seem to like when we try to export an object that's stored in a list, however. (Though it does just fine at exporting the entire list.) Here's an examplemodule.Rfile:The above example uses explicit export naming, which is brought up as a separate issue here (#19).
It could also be nice to simply export all objects in a list, as I naïvely tried when experimenting with
modules, e.g. theexportcall in the example above could be imagined like so:... i.e. where
my_exportsin the example is a named list of objects to export. I realize this introduces the error-handling behavior of 'what to do if there are unnamed list elements' ... I'd propose failing-fast in that case.Perhaps a separate
exportwrapper function entirely that necessitates named elements? (Or even an option, like.require_name = <TRUE/FALSE>that forces naming behavior?)