[Rd] removeSource() vs. function literals

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Wed Apr 5 09:03:03 CEST 2023


On Fri, 31 Mar 2023 08:49:53 +0200
Lionel Henry <lionel using posit.co> wrote:

> If you can afford a dependency on rlang, `rlang::zap_srcref()` deals
> with this. It's recursive over expression vectors, calls (including
> calls to `function` and their hidden srcref arg), and function
> objects.

Thanks for the suggestion! I hope that the source reference argument in
the `function` calls is the last way a source reference could sneak by
in an expression obtained using substitute().

> It's implemented in C for efficiency as we found it to be a
> bottleneck in some applications (IIRC caching). I'd be happy to
> upstream this in base if R core is interested.

A removeSource() that handles all the corner cases would be a nice
improvement.

-- 
Best regards,
Ivan



More information about the R-devel mailing list