klmr / box

Write reusable, composable and modular R code
https://klmr.me/box/
MIT License
862 stars 48 forks source link

Bugs when debugging functions in box #243

Closed beyondpie closed 2 years ago

beyondpie commented 3 years ago

Hi, I really like the module concept you introduce in R. Previously, I use your module package, and seems everything is OK. When I use box, I notice that the weird behaviors while in debug mode:

If I want to debug a function named boo in a R script name foo.R, which is import by box::use(foo), and I use debug(foo$boo).

Not sure if you have the similar experience?

Thanks! Songpeng

beyondpie commented 3 years ago

This is not happened in your old modules package. Also, I find it's easy for me load a script named foo_2-0.R like modules::import("foo_2-0"); while in box, when I use box(foo_2-0), it will treat it as foo_2 minus 0. How can I load script like "foo_2-0" in box?

klmr commented 3 years ago

I cannot reproduce this issue: debugging works just fine for me. Could you produce a step-by-step example to reproduce this?

klmr commented 3 years ago

when I use box(foo_2-0), it will treat it as foo_2 minus 0. How can I load script like "foo_2-0" in box?

As noted in the documentation, module names need to be valid R names. Non-syntactic names (such as foo_2-0) need to be escaped, just like other R names. The following works (assuming this is a local module):

box::use(./`foo_2-0`)

Fundamentally, users are encouraged to choose valid R names for their module names — same as for packages.

klmr commented 2 years ago

I’m assuming this issue is resolved?

If not, please reopen with a minimal reproducible example.

beyondpie commented 2 years ago

Thanks! You can close it. Recently I just move back to your original package, and use it without troubles. I may test box later when I have time.