Skip to content

removeSource() vs. function literals

1 message · Ivan Krylov

#
Thanks for the comments and sorry I didn't reply sooner!

On Thu, 30 Mar 2023 12:38:24 -0400
Duncan Murdoch <murdoch.duncan at gmail.com> wrote:

            
In my efforts to get arbitrary objects to hash consistently, I already
walk them recursively, but I do stop at environments. (In theory, it
could be possible to create mock environments with the same
relationships between each other and then "fix up" and hash their
contents, but it's hard to do right. Imagine environments e1 and e2
where e1$other <- e2 and e2$other <- e1.)

I think that removeSource() already walks language objects recursively,
it just doesn't remove source references from unevaluated function
expressions.
I receive the expression object from substitute(). The idea is to hash
the expression, locate and hash its dependencies and then see if
there's already a file named like the resulting hash. In theory, the
user could be constructing elaborate scary-looking expressions and then
calling my function on them, but I think I can be reasonably certain I
get the calls straight from the parser. Unfortunately, this doesn't put
me in a position to be controlling options(keep.source=...).
Thanks for this idea! At some point I was considering hashing text
representations of objects, but then I got serialize()-hashing working
and forgot about it.