Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't inhibit errors in user supplied generators #9

Open
vspinu opened this issue May 16, 2016 · 1 comment
Open

don't inhibit errors in user supplied generators #9

vspinu opened this issue May 16, 2016 · 1 comment

Comments

@vspinu
Copy link

vspinu commented May 16, 2016

Currently all user errors are swallowed by try blocks in r_list:

> r_data_frame(10,
+              id = sample(NULL, 10),
+              answer())
Error in sample(NULL, 10, n = 10) (from r_list.R#71) : unused argument (n = 10)
> 

which is unrelated to the real problem

> sample(NULL, 10)
Error in sample.int(length(x), size, replace, prob) : 
  invalid first argument

BTW, you can eliminate such errors and avoid the substitution of each var_function by having a smart n argument that would automatically pick n from the calling environment:

> var_fun <- function(a = get(".N.", parent.frame(1))){print(a)}
> caller <- function(){ .N. <- 10; var_fun()}
> caller()
[1] 10
@trinker
Copy link
Owner

trinker commented May 17, 2016

@vspinu Definitely a valid point I didn't realize was happening. I agree fully so long as the user's experience isn't changed (or at least not lowered). I don't have a lot of dev time at the moment. A pull request for the fix would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants