I would like to write an interpreter recursively memoizing Scheme . At any point in the evaluation, the interpreter should be able to detect when it receives as arguments a pair of expressions and environments that it has previously seen.
Plain memoization evaland applyinefficient . This would require looking for arguments in the hash table with every call to eval/ apply, which would require enumerating all (possibly large) arguments in the hash table.
For example, suppose an interpreter evaluates a program
(car (list A))
where A evaluates a large object. When the interpreter evaluates the application (list A), it first evaluates listand Aindividually. Before he applies listto A, he looks in his hash table to see if this application has seen this before, going all over Ato calculate the hash. Later, when the memoizing interpreter applies carto a list containing A, it computes a hash for that list, which again includes walking around the entire object A.
Instead, I want to build an interpreter that gradually builds up approximately unique hashes , avoiding, if possible, recalculation and ensuring that collisions are unlikely.
, , MD5 , , , MD5 . /, . , , . /, .
, / ?