Skip to content

Expected or unexpected behavior? Use() with alias attaches more namespaces than specified #364

Answered by klmr
SaintRod asked this question in Q&A
Discussion options

You must be logged in to vote

“attach” in the context of ‘box’ means the same as it does in R generally. That is: make a name available in the current scope directly, without the need to explicitly qualify their package/module name.

If being able to use a function not specified in the attach specification is expected behavior, then what's the difference between foo = purrr[chuck] vs foo = purrr[...]?

The difference is that the first one only attaches chuck(), the second attaches all exports of the ‘purrr’ package:

box::use(foo = purrr[chuck])
pluck(letters, 1L)  # fails
box::use(foo = purrr[...])
pluck(letters, 1L)  # succeeds

In fact, the presence of the module alias (foo =) is unrelated to the question of what nam…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@SaintRod
Comment options

@klmr
Comment options

Answer selected by SaintRod
@SaintRod
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants