coro icon indicating copy to clipboard operation
coro copied to clipboard

How to pass rcmdcheck using generators

Open latot opened this issue 9 months ago • 2 comments

Hi all, I'm trying to use generators inside a library, but after declaring a generator and using it this happens:

f_iterator <- coro::generator(function(ret, from, to) {
    for (id in seq(length(from))){
      coro::yield(list(
        from = from[[id]],
        to = to[[id]],
        distance = ret[[id]]
      ))
    }
})
  f_iterator : <anonymous>: no visible
    binding for global variable ‘generator_env’
  f_iterator : <anonymous>: no visible
    binding for global variable ‘exits’
  Undefined global functions or variables:
    exits generator_env id

What is the right way to handle this?

Usually, with rcmdcheck, use global variables are more like a workaround than a proper fix.

Thx!

latot avatar Sep 06 '23 12:09 latot