Changeset 14513 in project


Ignore:
Timestamp:
04/30/09 18:35:12 (11 years ago)
Author:
Kon Lovett
Message:

Save.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/lookup-table/trunk/lookup-table.scm

    r14486 r14513  
    99  (local)
    1010  (no-procedure-checks) )
    11 
    12 (include "chicken-primitive-object-inlines")
    13 (include "chicken-primitive-alist")
    14 (include "chicken-primitive-srfi-9")
    15 (include "inline-type-checks")
    16 
    17 ;;; Variant Dictionary
    18 
    19 (define-record-type/unsafe-inline-unchecked dict
    20         (%make-dict data)
    21         %dict?
    22         (data %dict-data-ref %dict-data-set!)
    23         (test %dict-test-ref %dict-test-set!)
    24         (to-alist %dict->alist-ref %dict->alist-set!)
    25         (ref %dict-ref-ref %dict-ref-set!)
    26         (set %dict-set-ref %dict-set-set!)
    27         (delete %dict-delete-ref %dict-delete-set!)
    28         (for-each %dict-for-each-ref %dict-for-each-set!)
    29         (merge %dict-merge-ref %dict-merge-set!)
    30         (search %dict-search-ref %dict-search-set!)
    31         (count %dict-count-ref %dict-count-set!)
    32         (keys %dict-keys-ref %dict-keys-set!)
    33         (values %dict-values-ref %dict-values-set!)
    34         (exists %dict-exists-ref %dict-exists-set!) )
    35 
    36 (define-inline (%set-dict-procs! dict tst to ref set del for mrg sch cnt keys vals exsts)
    37         (%dict-test-set! dict tst)
    38         (%dict->alist-set! dict to)
    39         (%dict-ref-set! dict ref)
    40         (%dict-set-set! dict set)
    41         (%dict-delete-set! dict del)
    42         (%dict-for-each-set! dict for)
    43         (%dict-merge-set! dict mrg)
    44         (%dict-search-set! dict sch)
    45         (%dict-count-set! dict cnt)
    46         (%dict-keys-set! dict keys)
    47         (%dict-values-set! dict vals)
    48         (%dict-exists-set! dict exsts)
    49         dict )
    50 
    51 (define-inline (%dict-test dict) ((%dict-test-ref dict) (%dict-data-ref dict)))
    52 (define-inline (%dict->alist dict) ((%dict->alist-ref dict) (%dict-data-ref dict)))
    53 (define-inline (%dict-ref dict key def) ((%dict-ref-ref dict) (%dict-data-ref dict) key def))
    54 (define-inline (%dict-set! dict key val) ((%dict-set-ref dict) (%dict-data-ref dict) key val))
    55 (define-inline (%dict-delete! dict key) ((%dict-delete-ref dict) (%dict-data-ref dict) key))
    56 (define-inline (%dict-for-each dict proc) ((%dict-for-each-ref dict) (%dict-data-ref dict) proc))
    57 (define-inline (%dict-merge dict1 dict2) ((%dict-merge-ref dict1) (%dict-data-ref dict1) (%dict-data-ref dict2)))
    58 (define-inline (%dict-search dict proc def) ((%dict-search-ref dict) (%dict-data-ref dict) proc def))
    59 (define-inline (%dict-count dict) ((%dict-count-ref dict) (%dict-data-ref dict)))
    60 (define-inline (%dict-keys dict) ((%dict-keys-ref dict) (%dict-data-ref dict)))
    61 (define-inline (%dict-values dict) ((%dict-values-ref dict) (%dict-data-ref dict)))
    62 (define-inline (%dict-exists? dict key) ((%dict-exists-ref dict) (%dict-data-ref dict) key))
    63 
    64 ;; Association List
    65 
    66 (define-inline (%make-alist-data test al) (%cons test al))
    67 (define-inline (%alist-dict-test data) (%car data))
    68 (define-inline (%alist-dict-alist data) (%cdr data))
    69 (define-inline (%alist-dict-alist-set! data al) (%set-cdr! data al))
    70 
    71 (define-inline (%set-alist-dict-procs! dict)
    72         (%set-dict-procs! dict
    73                 alist-dict-test-ref
    74                 alist-dict->alist
    75                 alist-dict-ref
    76                 alist-dict-set
    77                 alist-dict-delete
    78                 alist-dict-for-each
    79                 alist-dict-merge
    80                 alist-dict-search
    81                 alist-dict-count
    82                 alist-dict-keys
    83                 alist-dict-values
    84                 alist-dict-exists?) )
    85 
    86 ;; Hash Table
    87 
    88 (define-inline (%make-htable-data test ht) (%cons test ht))
    89 (define-inline (%htable-dict-test data) (%car data))
    90 (define-inline (%htable-dict-htable data) (%cdr data))
    91 (define-inline (%htable-dict-htable-set! data ht) (%set-cdr! data ht))
    92 
    93 (define-inline (%set-htable-dict-procs! dict)
    94         (%set-dict-procs! dict
    95                 htable-dict-test-ref
    96                 htable-dict->alist
    97                 htable-dict-ref
    98                 htable-dict-set
    99                 htable-dict-delete
    100                 htable-dict-for-each
    101                 htable-dict-merge
    102                 htable-dict-search
    103                 htable-dict-count
    104                 htable-dict-keys
    105                 htable-dict-values
    106                 htable-dict-exists?) )
    107 
    108 ;; Dictionary Type
    109 
    110 (define-inline (%dict-same-kind? dict1 dict2)
    111   (%eq? (%dict-test-ref dict1) (%dict-test-ref dict2)) )
    112 
    113 (define-inline (%dict-same-test? dict1 dict2) (%eq? (%dict-test dict1) (%dict-test dict2)))
    114 
    115 (define-inline (%dict-bestfit dict)
    116         (if (%fx< MAGIC-LIMIT (%dict-count dict))
    117       (unless (htable-dict? dict) (become-htable-dict dict))
    118       (unless (alist-dict? dict) (become-alist-dict dict)) ) )
    119 
    120 ;; Argument Checks
    121 
    122 (define-inline-check-type dict)
    123 
    124 (define-inline (%check-value loc obj)
    125   (when (%undefined-value? obj) (error-argument-type loc obj "non-undefined value")) )
    126 
    127 ;; Element count when hash-table faster
    128 ;; (your milage may vary)
    129 
    130 (define-constant MAGIC-LIMIT 12)
    13111
    13212;;;
     
    15434  dict-print )
    15535
    156 (import scheme chicken srfi-1 srfi-69 ports data-structures extras miscmacros type-errors)
    157 (require-library srfi-1 srfi-69 extras miscmacros type-errors)
     36(import scheme chicken srfi-1 srfi-69 ports data-structures extras miscmacros type-checks type-errors)
     37(require-library srfi-1 srfi-69 extras miscmacros type-checks type-errors)
     38
     39;;; Variant Dictionary
     40
     41(define-record-type dict
     42        (make-dict data)
     43        dict?
     44        (data dict-data-ref dict-data-set!)
     45        (test dict-test-ref dict-test-set!)
     46        (to-alist dict->alist-ref dict->alist-set!)
     47        (ref dict-ref-ref dict-ref-set!)
     48        (set dict-set-ref dict-set-set!)
     49        (delete dict-delete-ref dict-delete-set!)
     50        (for-each dict-for-each-ref dict-for-each-set!)
     51        (merge dict-merge-ref dict-merge-set!)
     52        (search dict-search-ref dict-search-set!)
     53        (count dict-count-ref dict-count-set!)
     54        (keys dict-keys-ref dict-keys-set!)
     55        (values dict-values-ref dict-values-set!)
     56        (exists dict-exists-ref dict-exists-set!) )
     57
     58(define (set-dict-procs! dict tst to ref set del for mrg sch cnt keys vals exsts)
     59        (dict-test-set! dict tst)
     60        (dict->alist-set! dict to)
     61        (dict-ref-set! dict ref)
     62        (dict-set-set! dict set)
     63        (dict-delete-set! dict del)
     64        (dict-for-each-set! dict for)
     65        (dict-merge-set! dict mrg)
     66        (dict-search-set! dict sch)
     67        (dict-count-set! dict cnt)
     68        (dict-keys-set! dict keys)
     69        (dict-values-set! dict vals)
     70        (dict-exists-set! dict exsts)
     71        dict )
     72
     73(define (dict-test dict) ((dict-test-ref dict) (dict-data-ref dict)))
     74(define (dict->alist dict) ((dict->alist-ref dict) (dict-data-ref dict)))
     75(define (dict-ref dict key def) ((dict-ref-ref dict) (dict-data-ref dict) key def))
     76(define (dict-set! dict key val) ((dict-set-ref dict) (dict-data-ref dict) key val))
     77(define (dict-delete! dict key) ((dict-delete-ref dict) (dict-data-ref dict) key))
     78(define (dict-for-each dict proc) ((dict-for-each-ref dict) (dict-data-ref dict) proc))
     79(define (dict-merge dict1 dict2) ((dict-merge-ref dict1) (dict-data-ref dict1) (dict-data-ref dict2)))
     80(define (dict-search dict proc def) ((dict-search-ref dict) (dict-data-ref dict) proc def))
     81(define (dict-count dict) ((dict-count-ref dict) (dict-data-ref dict)))
     82(define (dict-keys dict) ((dict-keys-ref dict) (dict-data-ref dict)))
     83(define (dict-values dict) ((dict-values-ref dict) (dict-data-ref dict)))
     84(define (dict-exists? dict key) ((dict-exists-ref dict) (dict-data-ref dict) key))
     85
     86;; Association List
     87
     88(define (make-alist-data test al) (cons test al))
     89(define (alist-dict-test data) (car data))
     90(define (alist-dict-alist data) (cdr data))
     91(define (alist-dict-alist-set! data al) (set-cdr! data al))
     92
     93(define (set-alist-dict-procs! dict)
     94        (set-dict-procs! dict
     95                alist-dict-test-ref
     96                alist-dict->alist
     97                alist-dict-ref
     98                alist-dict-set
     99                alist-dict-delete
     100                alist-dict-for-each
     101                alist-dict-merge
     102                alist-dict-search
     103                alist-dict-count
     104                alist-dict-keys
     105                alist-dict-values
     106                alist-dict-exists?) )
     107
     108;; Hash Table
     109
     110(define (make-htable-data test ht) (cons test ht))
     111(define (htable-dict-test data) (car data))
     112(define (htable-dict-htable data) (cdr data))
     113(define (htable-dict-htable-set! data ht) (set-cdr! data ht))
     114
     115(define (set-htable-dict-procs! dict)
     116        (set-dict-procs! dict
     117                htable-dict-test-ref
     118                htable-dict->alist
     119                htable-dict-ref
     120                htable-dict-set
     121                htable-dict-delete
     122                htable-dict-for-each
     123                htable-dict-merge
     124                htable-dict-search
     125                htable-dict-count
     126                htable-dict-keys
     127                htable-dict-values
     128                htable-dict-exists?) )
     129
     130;; Dictionary Type
     131
     132(define (dict-same-kind? dict1 dict2)
     133  (eq? (dict-test-ref dict1) (dict-test-ref dict2)) )
     134
     135(define (dict-same-test? dict1 dict2) (eq? (dict-test dict1) (dict-test dict2)))
     136
     137(define (dict-bestfit dict)
     138        (if (fx< MAGIC-LIMIT (dict-count dict))
     139      (unless (htable-dict? dict) (become-htable-dict dict))
     140      (unless (alist-dict? dict) (become-alist-dict dict)) ) )
     141
     142;; Argument Checks
     143
     144(define-check-type dict)
     145
     146(define (check-value loc obj)
     147  (when (undefined-value? obj) (error-argument-type loc obj "non-undefined value")) )
     148
     149;; Element count when hash-table faster
     150;; (your milage may vary)
     151
     152(define-constant MAGIC-LIMIT 12)
    158153
    159154;;;
     
    165160;;; Alist Dictionary
    166161
    167 (define (alist-dict-test-ref data) (%alist-dict-test data))
     162(define (alist-dict-test-ref data) (alist-dict-test data))
    168163
    169164(define (alist-dict->alist data)
    170   (let ((dat (%alist-dict-alist data)))
     165  (let ((dat (alist-dict-alist data)))
    171166    (if *dict-safe-mode* (list-copy dat)
    172167        dat ) ) )
    173168
    174169(define (alist-dict-ref data key def)
    175         (%alist-ref key (%alist-dict-alist data) (%alist-dict-test data) def) )
     170        (alist-ref key (alist-dict-alist data) (alist-dict-test data) def) )
    176171
    177172(define (alist-dict-set data key obj)
    178         (%alist-dict-alist-set!
     173        (alist-dict-alist-set!
    179174         data
    180    (%alist-update! key obj (%alist-dict-alist data) (%alist-dict-test data))) )
     175   (alist-update! key obj (alist-dict-alist data) (alist-dict-test data))) )
    181176
    182177(define (alist-dict-delete data key)
    183         (%alist-dict-alist-set!
     178        (alist-dict-alist-set!
    184179         data
    185    (%alist-delete! key (%alist-dict-alist data) (%alist-dict-test data))) )
     180   (alist-delete! key (alist-dict-alist data) (alist-dict-test data))) )
    186181
    187182(define (alist-dict-for-each data proc)
    188         (%list-for-each/1 (lambda (cell) (proc (%car cell) (%cdr cell)))
    189                           (%alist-dict-alist data)) )
     183        (list-for-each/1 (lambda (cell) (proc (car cell) (cdr cell)))
     184                          (alist-dict-alist data)) )
    190185
    191186(define (alist-dict-merge data1 data2)
    192         (let ((test (%alist-dict-test data1))
    193               (al (%alist-dict-alist data1)))
    194                 (%list-for-each/1 (lambda (cell)
    195                                     (set! al (%alist-update! (%car cell) (%cdr cell) al test)))
    196                                         (%alist-dict-alist data2))
    197                 (%alist-dict-alist-set! data1 al) ) )
    198 
    199 (define (alist-dict-search data proc def) (%alist-find proc (%alist-dict-alist data) def))
    200 
    201 (define (alist-dict-count data) (%length (%alist-dict-alist data)))
    202 
    203 (define (alist-dict-keys data) (%list-map/1 (lambda (x) (%car x)) (%alist-dict-alist data)))
    204 
    205 (define (alist-dict-values data) (%list-map/1 (lambda (x) (%cdr x)) (%alist-dict-alist data)))
     187        (let ((test (alist-dict-test data1))
     188              (al (alist-dict-alist data1)))
     189                (list-for-each/1 (lambda (cell)
     190                                    (set! al (alist-update! (car cell) (cdr cell) al test)))
     191                                        (alist-dict-alist data2))
     192                (alist-dict-alist-set! data1 al) ) )
     193
     194(define (alist-dict-search data proc def) (alist-find proc (alist-dict-alist data) def))
     195
     196(define (alist-dict-count data) (length (alist-dict-alist data)))
     197
     198(define (alist-dict-keys data) (list-map/1 (lambda (x) (car x)) (alist-dict-alist data)))
     199
     200(define (alist-dict-values data) (list-map/1 (lambda (x) (cdr x)) (alist-dict-alist data)))
    206201
    207202(define (alist-dict-exists? data key)
    208         (not (%undefined-value? (alist-dict-ref data key (%undefined-value)))) )
     203        (not (undefined-value? (alist-dict-ref data key (undefined-value)))) )
    209204
    210205(define (make-alist-dict test al)
    211   (%set-alist-dict-procs! (%make-dict (%make-alist-data test al))) )
    212 
    213 (define (alist-dict? dict) (%eq? alist-dict-test-ref (%dict-test dict)))
     206  (set-alist-dict-procs! (make-dict (make-alist-data test al))) )
     207
     208(define (alist-dict? dict) (eq? alist-dict-test-ref (dict-test dict)))
    214209
    215210(define (become-alist-dict dict)
    216         (%dict-data-set! dict (%make-alist-data (%dict-test dict) (%dict->alist dict)))
    217         (%set-alist-dict-procs! dict) )
     211        (dict-data-set! dict (make-alist-data (dict-test dict) (dict->alist dict)))
     212        (set-alist-dict-procs! dict) )
    218213
    219214;;; Hash-table Dictionary
    220215
    221 (define (htable-dict-test-ref data) (%htable-dict-test data))
    222 
    223 (define (htable-dict->alist data) (hash-table->alist (%htable-dict-htable data)))
     216(define (htable-dict-test-ref data) (htable-dict-test data))
     217
     218(define (htable-dict->alist data) (hash-table->alist (htable-dict-htable data)))
    224219
    225220(define (htable-dict-ref data key def)
    226         (hash-table-ref/default (%htable-dict-htable data) key def) )
     221        (hash-table-ref/default (htable-dict-htable data) key def) )
    227222
    228223(define (htable-dict-set data key obj)
    229         (hash-table-set! (%htable-dict-htable data) key obj) )
     224        (hash-table-set! (htable-dict-htable data) key obj) )
    230225
    231226(define (htable-dict-delete data key)
    232         (hash-table-delete! (%htable-dict-htable data) key) )
     227        (hash-table-delete! (htable-dict-htable data) key) )
    233228
    234229(define (htable-dict-for-each data proc)
    235         (hash-table-for-each (%htable-dict-htable data) proc) )
     230        (hash-table-for-each (htable-dict-htable data) proc) )
    236231
    237232(define (htable-dict-merge data1 data2)
    238         (%htable-dict-htable-set!
     233        (htable-dict-htable-set!
    239234         data1
    240          (hash-table-merge! (%htable-dict-htable data1) (%htable-dict-htable data2))) )
     235         (hash-table-merge! (htable-dict-htable data1) (htable-dict-htable data2))) )
    241236
    242237(define (htable-dict-search data proc def)
    243         (let ((ht (%htable-dict-htable data))
     238        (let ((ht (htable-dict-htable data))
    244239                                (ret #f))
    245240                (let ((res (let/cc return
     
    248243                        (if ret res def) ) ) )
    249244
    250 (define (htable-dict-count data) (hash-table-size (%htable-dict-htable data)))
    251 
    252 (define (htable-dict-keys data) (hash-table-keys (%htable-dict-htable data)))
    253 
    254 (define (htable-dict-values data) (hash-table-values (%htable-dict-htable data)))
    255 
    256 (define (htable-dict-exists? data key) (hash-table-exists? (%htable-dict-htable data) key))
     245(define (htable-dict-count data) (hash-table-size (htable-dict-htable data)))
     246
     247(define (htable-dict-keys data) (hash-table-keys (htable-dict-htable data)))
     248
     249(define (htable-dict-values data) (hash-table-values (htable-dict-htable data)))
     250
     251(define (htable-dict-exists? data key) (hash-table-exists? (htable-dict-htable data) key))
    257252
    258253(define (make-htable-dict test ht)
    259   (%set-htable-dict-procs! (%make-dict (%make-htable-data test ht))) )
    260 
    261 (define (htable-dict? dict) (%eq? htable-dict-test-ref (%dict-test dict)))
     254  (set-htable-dict-procs! (make-dict (make-htable-data test ht))) )
     255
     256(define (htable-dict? dict) (eq? htable-dict-test-ref (dict-test dict)))
    262257
    263258(define (become-htable-dict dict)
    264         (let ((test (%dict-test dict)))
    265                 (%dict-data-set! dict (%make-htable-data test (alist->hash-table (%dict->alist dict) test))))
    266         (%set-htable-dict-procs! dict) )
     259        (let ((test (dict-test dict)))
     260                (dict-data-set! dict (make-htable-data test (alist->hash-table (dict->alist dict) test))))
     261        (set-htable-dict-procs! dict) )
    267262
    268263;; Errors
     
    274269(define (*dict-print dict)
    275270  ((rec (print-node-table dict spcr)
    276     (%dict-for-each dict
     271    (dict-for-each dict
    277272      (lambda (key val)
    278         (%list-for-each/1 display spcr)
    279         (cond ((%dict? val)
     273        (list-for-each/1 display spcr)
     274        (cond ((dict? val)
    280275                (write key) (display " :") (newline)
    281                 (print-node-table val (%cons "  " spcr)))
     276                (print-node-table val (cons "  " spcr)))
    282277              (else
    283278                (write key) (display " : ") (pretty-print val))))))
     
    286281(define (*dict-update! dict key valu-func updt-func curr loc)
    287282  (let ((val (updt-func
    288               (if (not (%undefined-value? curr)) curr
     283              (if (not (undefined-value? curr)) curr
    289284                  (let ((val (valu-func)))
    290                     (when *dict-safe-mode* (%check-value loc val))
     285                    (when *dict-safe-mode* (check-value loc val))
    291286                    val ) ) ) ) )
    292     (%dict-set! dict key val)
     287    (dict-set! dict key val)
    293288    val ) )
    294289
    295290(define (+dict-update! dict key valu-func updt-func loc)
    296291  (when *dict-safe-mode*
    297     (%check-dict loc dict)
    298     (%check-procedure loc valu-func)
    299     (%check-procedure loc updt-func) )
    300   (let* ((curr (%dict-ref dict key (%undefined-value)))
     292    (check-dict loc dict)
     293    (check-procedure loc valu-func)
     294    (check-procedure loc updt-func) )
     295  (let* ((curr (dict-ref dict key (undefined-value)))
    301296         (updt (*dict-update! dict key valu-func updt-func curr loc)))
    302     (unless (%undefined-value? curr) (%dict-bestfit dict))
     297    (unless (undefined-value? curr) (dict-bestfit dict))
    303298    updt ) )
    304299
     
    312307(define (make-dict #!optional (test eq?) (size 0))
    313308  (when *dict-safe-mode*
    314     (%check-cardinal-fixnum 'make-dict size "size")
    315     (%check-procedure 'make-dict test) )
    316         (if (%fx< MAGIC-LIMIT size)
     309    (check-cardinal-fixnum 'make-dict size "size")
     310    (check-procedure 'make-dict test) )
     311        (if (fx< MAGIC-LIMIT size)
    317312      (make-htable-dict test (make-hash-table test))
    318313      (make-alist-dict test '())) )
     
    320315(define (alist->dict al #!optional (test eq?) (size 0))
    321316  (when *dict-safe-mode*
    322     (%check-cardinal-fixnum 'alist->dict size "size")
    323     (%check-procedure 'alist->dict test) )
    324         (if (or (%fx< MAGIC-LIMIT size) (%fx< MAGIC-LIMIT (%length al)))
     317    (check-cardinal-fixnum 'alist->dict size "size")
     318    (check-procedure 'alist->dict test) )
     319        (if (or (fx< MAGIC-LIMIT size) (fx< MAGIC-LIMIT (length al)))
    325320      (make-htable-dict test (alist->hash-table al test))
    326321      (make-alist-dict test al)) )
    327322
    328323(define (dict->alist dict)
    329   (when *dict-safe-mode* (%check-dict 'dict->alist dict))
    330         (%dict->alist dict) )
    331 
    332 (define (dict? obj) (%dict? obj))
     324  (when *dict-safe-mode* (check-dict 'dict->alist dict))
     325        (dict->alist dict) )
    333326
    334327(define (dict-equivalence-function dict)
    335   (when *dict-safe-mode* (%check-dict 'dict-equivalence-function dict))
    336         (%dict-test dict) )
     328  (when *dict-safe-mode* (check-dict 'dict-equivalence-function dict))
     329        (dict-test dict) )
    337330
    338331(define (dict-count dict)
    339   (when *dict-safe-mode* (%check-dict 'dict-count dict))
    340         (%dict-count dict) )
     332  (when *dict-safe-mode* (check-dict 'dict-count dict))
     333        (dict-count dict) )
    341334
    342335(define (dict-keys dict)
    343   (when *dict-safe-mode* (%check-dict 'dict-keys dict))
    344         (%dict-keys dict) )
     336  (when *dict-safe-mode* (check-dict 'dict-keys dict))
     337        (dict-keys dict) )
    345338
    346339(define (dict-values dict)
    347   (when *dict-safe-mode* (%check-dict 'dict-values dict))
    348         (%dict-values dict) )
     340  (when *dict-safe-mode* (check-dict 'dict-values dict))
     341        (dict-values dict) )
    349342
    350343(define (dict-ref dict key #!optional def)
    351   (when *dict-safe-mode* (%check-dict 'dict-ref dict))
    352         (%dict-ref dict key def) )
     344  (when *dict-safe-mode* (check-dict 'dict-ref dict))
     345        (dict-ref dict key def) )
    353346
    354347(define (dict-set! dict key obj)
    355348  (when *dict-safe-mode*
    356     (%check-value 'dict-set! obj)
    357     (%check-dict 'dict-set! dict) )
    358         (%dict-set! dict key obj)
    359         (%dict-bestfit dict) )
     349    (check-value 'dict-set! obj)
     350    (check-dict 'dict-set! dict) )
     351        (dict-set! dict key obj)
     352        (dict-bestfit dict) )
    360353
    361354(define (dict-exists? dict key)
    362   (when *dict-safe-mode* (%check-dict 'dict-exists? dict))
    363   (%dict-exists? dict key) )
     355  (when *dict-safe-mode* (check-dict 'dict-exists? dict))
     356  (dict-exists? dict key) )
    364357
    365358(define (dict-update! dict key valu-func #!optional (updt-func identity))
     
    373366
    374367(define (dict-delete! dict key)
    375   (when *dict-safe-mode* (%check-dict 'dict-delete! dict))
    376         (%dict-delete! dict key)
    377         (%dict-bestfit dict) )
     368  (when *dict-safe-mode* (check-dict 'dict-delete! dict))
     369        (dict-delete! dict key)
     370        (dict-bestfit dict) )
    378371
    379372(define (dict-for-each dict proc)
    380373  (when *dict-safe-mode*
    381     (%check-dict 'dict-for-each dict)
    382     (%check-procedure 'dict-for-each proc) )
    383         (%dict-for-each dict proc) )
     374    (check-dict 'dict-for-each dict)
     375    (check-procedure 'dict-for-each proc) )
     376        (dict-for-each dict proc) )
    384377
    385378(define (dict-search dict proc #!optional def)
    386379  (when *dict-safe-mode*
    387     (%check-dict 'dict-search dict)
    388     (%check-procedure 'dict-search proc) )
    389         (%dict-search dict proc def) )
     380    (check-dict 'dict-search dict)
     381    (check-procedure 'dict-search proc) )
     382        (dict-search dict proc def) )
    390383
    391384(define (dict-merge! dict . dicts)
    392   (when *dict-safe-mode* (%check-dict 'dict-merge! dict))
    393         (%list-for-each/1
     385  (when *dict-safe-mode* (check-dict 'dict-merge! dict))
     386        (list-for-each/1
    394387                (lambda (dictx)
    395388      (when *dict-safe-mode*
    396         (%check-dict 'dict-merge! dictx)
    397         (unless (%dict-same-test? dict dictx)
     389        (check-dict 'dict-merge! dictx)
     390        (unless (dict-same-test? dict dictx)
    398391          (error "cannot merge lookup-tables; incompatible test") ) )
    399                         (if (%dict-same-kind? dict dictx) (%dict-merge dict dictx)
    400           (%dict-for-each dictx (cut %dict-set! dict <> <>)) ) )
     392                        (if (dict-same-kind? dict dictx) (dict-merge dict dictx)
     393          (dict-for-each dictx (cut dict-set! dict <> <>)) ) )
    401394                dicts)
    402         (%dict-bestfit dict) )
     395        (dict-bestfit dict) )
    403396
    404397(define (dict-print dict #!optional port)
Note: See TracChangeset for help on using the changeset viewer.