From kry|ov@r00t @end|ng |rom gm@||@com  Wed Apr  5 09:03:03 2023
From: kry|ov@r00t @end|ng |rom gm@||@com (Ivan Krylov)
Date: Wed, 5 Apr 2023 10:03:03 +0300
Subject: [Rd] removeSource() vs. function literals
In-Reply-To: <CAJf4E3pF-SOgch5AKgx2aLb27amSCd4wUuDhd-MokF9h8ggVQA@mail.gmail.com>
References: <20230330173239.72da4e14@arachnoid>
 <509b2249-d533-6f15-5b14-c5cfb8218059@gmail.com>
 <CAJf4E3pF-SOgch5AKgx2aLb27amSCd4wUuDhd-MokF9h8ggVQA@mail.gmail.com>
Message-ID: <20230405100303.75bc4a37@Tarkus>

On Fri, 31 Mar 2023 08:49:53 +0200
Lionel Henry <lionel at 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



[Rd] removeSource() vs. function literals
Ivan Krylov