CredibilityLab / groundhog

Reproducible R Scripts Via Date Controlled Installing & Loading of CRAN & Git Packages
https://groundhogr.com/
GNU General Public License v3.0
78 stars 4 forks source link

Add Uri's change #47

Closed Bisaloo closed 4 years ago

Bisaloo commented 4 years ago

@urisohn, I added some comments (some for me, some for you). Could you have a look please? I'll try to do the necessary changes in the next days.

urisohn commented 4 years ago

"> We already talked a bit about this but my main issue is with the stop2() function."

I thought you did not like it out of principle that a stop() should be a stop() and i thought this was easy enough, and the 'early return' solution cannot be implemented, I don't think, in stand-alone function for the return will just affect that stop2() function, not teh one calling it.

So sure, let's go with the solution you propose to prevent "Error" appearing when it's not expected.

When it is not possible to mke the NULL invisible, i prefer having the error message show up that [1] NULL

Bisaloo commented 4 years ago

Okay, this was a bit tricky but I found a clean way to do this. We can define an exit() function for this:

exit <- function() {
  invokeRestart("abort")
}

test <- function() {
  message("this is the last message")
  exit()
  message("you should not see this")
}

test()

nested_test <- function() {
  test()
  message("you should not see this either")
}

nested_test()
urisohn commented 4 years ago

Great solution. Just tested successfully on R-3.0.1