r-gregmisc / gtools

Functions to assist in R programming
25 stars 6 forks source link

Warn that defmacro() can have side effects #8

Open RLesur opened 3 years ago

RLesur commented 3 years ago

Hi,

Thanks a lot for your work on this package.

I have a dummy question about defmacro(). Its documentation clearly mentions that it comes from Thomas Lumley's article in R News. This article indicates that

a macro would have undesirable side-effects

I had a hard time while debugging some programs which use defmacro() because of these side effects. I haven't used it before that and it was clear that the R users who had written these programs were not aware of the side effects of defmacro().

I wonder whether you would agree to warn users about using defmacro()?
Personnally, I am not convinced that using defmacro() is safe. IMHO, this function should only be used by advanced users who understand the risks.

warnes commented 3 years ago

I would be glad to add an appropriate warning. Can you suggest some text?