Submitted on 9 July 2004 at 16:27

On 11 July 2004 at 14:44 Jira commented:

STR-144, visser:
Refactored the definition of merge operations on pairs of hashtables. There is now a single (78 LOC!) rule that defines many different scenarios for merging two hashtables. This hashtable-merge rule takes as arguments a number of switches for choosing the desired scenario. For example, the following merge strategy is defined in terms of hashtable-merge:

       hashtable-intersect-wempty(|tbl2, emptyElt) =
         ?tbl1
         ; !(tbl1, tbl2)
         ; hashtable-merge(
             symmetric-no,
              iterate1-yes,
              iterate2-yes,
              remove-no,
              isect,
              !emptyElt,
               key -> <hashtable-get(|key)> tbl1 ,
               key -> <hashtable-get(|key)> tbl2 
         )

The -yes, -no strategies are synonyms for id and fail and serve to remind us of the choices made in the instantiation. When good use is made of compile-time inlining and evaluation (constant folding), the generic algorithm should be reduced to a fairly decent specialized algorithm.

Log in to post comments