Skip to content

Export from a list of objects #20

Description

@mmuurr

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?)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions