Changeset 13885 in project


Ignore:
Timestamp:
03/24/09 05:22:09 (11 years ago)
Author:
Kon Lovett
Message:

Renamed to canonical style - explicit inlines a '%', internal otherwise '*' & '+'.

Location:
release/3/lookup-table
Files:
1 edited
9 copied

Legend:

Unmodified
Added
Removed
  • release/3/lookup-table/tags/1.7.1/lookup-table.scm

    r13881 r13885  
    77  (inline)
    88  (no-procedure-checks)
     9  (disable-interrupts)
    910  (export
    1011    dict-safe-mode
     
    8081        dict )
    8182
    82 (define (%dict-test dict)
     83(define-inline (%dict-test dict)
    8384        ((%dict-test-ref dict) (%dict-data-ref dict)) )
    8485
    85 (define (%dict->alist dict)
     86(define-inline (%dict->alist dict)
    8687        ((%dict->alist-ref dict) (%dict-data-ref dict)) )
    8788
    88 (define (%dict-ref dict key def)
     89(define-inline (%dict-ref dict key def)
    8990        ((%dict-ref-ref dict) (%dict-data-ref dict) key def) )
    9091
    91 (define (%dict-set! dict key val)
     92(define-inline (%dict-set! dict key val)
    9293        ((%dict-set-ref dict) (%dict-data-ref dict) key val) )
    9394
    94 (define (%dict-delete! dict key)
     95(define-inline (%dict-delete! dict key)
    9596        ((%dict-delete-ref dict) (%dict-data-ref dict) key) )
    9697
    97 (define (%dict-for-each dict proc)
     98(define-inline (%dict-for-each dict proc)
    9899        ((%dict-for-each-ref dict) (%dict-data-ref dict) proc) )
    99100
    100 (define (%dict-merge dict1 dict2)
     101(define-inline (%dict-merge dict1 dict2)
    101102        ((%dict-merge-ref dict1) (%dict-data-ref dict1) (%dict-data-ref dict2)) )
    102103
    103 (define (%dict-search dict proc def)
     104(define-inline (%dict-search dict proc def)
    104105        ((%dict-search-ref dict) (%dict-data-ref dict) proc def) )
    105106
    106 (define (%dict-count dict)
     107(define-inline (%dict-count dict)
    107108        ((%dict-count-ref dict) (%dict-data-ref dict)) )
    108109
    109 (define (%dict-keys dict)
     110(define-inline (%dict-keys dict)
    110111        ((%dict-keys-ref dict) (%dict-data-ref dict)) )
    111112
    112 (define (%dict-values dict)
     113(define-inline (%dict-values dict)
    113114        ((%dict-values-ref dict) (%dict-data-ref dict)) )
    114115
    115 (define (%dict-exists? dict key)
     116(define-inline (%dict-exists? dict key)
    116117        ((%dict-exists-ref dict) (%dict-data-ref dict) key) )
    117118
    118119;;; Alist Dictionary
    119120
    120 (define (%alist-dict-test data)
     121(define-inline (%alist-dict-test data)
    121122        (car data) )
    122123
    123 (define (%alist-dict-alist data)
     124(define-inline (%alist-dict-alist data)
    124125        (cdr data) )
    125126
     
    141142
    142143(define (alist-dict-for-each data proc)
    143         (for-each (lambda (pair) (proc (car pair) (cdr pair))) (%alist-dict-alist data)) )
     144        (for-each (lambda (cell) (proc (car cell) (cdr cell))) (%alist-dict-alist data)) )
    144145
    145146(define (alist-dict-merge data1 data2)
    146147        (let ((test (%alist-dict-test data1)) (al (%alist-dict-alist data1)))
    147148                (for-each
    148                         (lambda (pair) (set! al (alist-update! (car pair) (cdr pair) al test)))
     149                        (lambda (cell) (set! al (alist-update! (car cell) (cdr cell) al test)))
    149150                        (%alist-dict-alist data2))
    150151                (set-cdr! data1 al) ) )
     
    153154        (let loop ((al (%alist-dict-alist data)))
    154155                (if (null? al) def
    155         (let* ((pair (car al))
    156                (val (cdr pair)))
    157             (if (proc (car pair) val) val
     156        (let* ((cell (car al))
     157               (val (cdr cell)))
     158            (if (proc (car cell) val) val
    158159                (loop (cdr al)) ) ) ) ) )
    159160
     
    198199;;; Hash-table Dictionary
    199200
    200 (define (%hash-table-dict-test data)
     201(define-inline (%hash-table-dict-test data)
    201202        (car data) )
    202203
    203 (define (%hash-table-dict-hash-table data)
     204(define-inline (%hash-table-dict-hash-table data)
    204205        (cdr data) )
    205206
     
    301302                (error loc "invalid dictionary" obj)) )
    302303
    303 (define (check-output-port obj loc)
    304   (unless (output-port? obj)
    305     (error loc "invalid output port" obj) ) )
    306 
    307304(define (check-value obj loc)
    308305  (when (eq? *unspecified* obj)
    309306    (error loc "invalid value" obj) ) )
    310307
    311 (define (%dict-print dict)
     308;;
     309
     310(define (*dict-print dict)
    312311  ((rec (print-node-table dict spcr)
    313312    (%dict-for-each dict
     
    321320    dict '()) )
    322321
    323 (define (%dict-update! dict key valu-func updt-func curr loc)
     322(define (*dict-update! dict key valu-func updt-func curr loc)
    324323  (let ((val (updt-func
    325324              (if (not (eq? *unspecified* curr)) curr
    326325                  (let ((val (valu-func)))
    327                     (when *dict-safe-mode*
    328                       (check-value val loc) )
     326                    (when *dict-safe-mode* (check-value val loc))
    329327                    val ) ) ) ) )
    330328    (%dict-set! dict key val)
    331329    val ) )
    332330
    333 ;;;
    334 
    335 (define (*dict-update! dict key valu-func updt-func loc)
     331(define (+dict-update! dict key valu-func updt-func loc)
    336332  (when *dict-safe-mode*
    337333    (check-dict dict loc)
     
    339335    (check-procedure updt-func loc) )
    340336  (let* ((curr (%dict-ref dict key *unspecified*))
    341          (updt (%dict-update! dict key valu-func updt-func curr loc)))
    342     (unless (eq? *unspecified* curr)
    343       (dict-bestfit dict) )
     337         (updt (*dict-update! dict key valu-func updt-func curr loc)))
     338    (unless (eq? *unspecified* curr) (dict-bestfit dict))
    344339    updt ) )
    345340
    346341;;; Globals
    347342
    348 (define-parameter dict-safe-mode
    349   *dict-safe-mode*
     343(define-parameter dict-safe-mode *dict-safe-mode*
    350344  (lambda (x)
    351345    (set! *dict-safe-mode* x)
     
    413407
    414408(define (dict-update! dict key valu-func #!optional (updt-func identity))
    415         (*dict-update! dict key valu-func updt-func 'dict-update!) )
     409        (+dict-update! dict key valu-func updt-func 'dict-update!) )
    416410
    417411(define (dict-update-list! dict key . vals)
    418   (*dict-update! dict key (lambda () '()) (cut fold cons <> (reverse! vals)) 'dict-update-list!) )
     412  (+dict-update! dict key (lambda () '()) (cut fold cons <> (reverse! vals)) 'dict-update-list!) )
    419413
    420414(define (dict-update-dict! dict key)
    421   (*dict-update! dict key (cut make-dict) identity 'dict-update-dict!) )
     415  (+dict-update! dict key (cut make-dict) identity 'dict-update-dict!) )
    422416
    423417(define (dict-delete! dict key)
     
    454448
    455449(define (dict-print dict #!optional port)
    456   (if (not port) (%dict-print dict)
    457       (begin
    458         (when *dict-safe-mode*
    459           (check-output-port port 'dict-print) )
    460         (with-output-to-port port (lambda () (%dict-print dict)) ) ) ) )
     450  (if (not port) (*dict-print dict)
     451      (with-output-to-port port (lambda () (*dict-print dict)) ) ) )
  • release/3/lookup-table/trunk/lookup-table.scm

    r13877 r13885  
    77  (inline)
    88  (no-procedure-checks)
     9  (disable-interrupts)
    910  (export
    1011    dict-safe-mode
     
    8081        dict )
    8182
    82 (define (%dict-test dict)
     83(define-inline (%dict-test dict)
    8384        ((%dict-test-ref dict) (%dict-data-ref dict)) )
    8485
    85 (define (%dict->alist dict)
     86(define-inline (%dict->alist dict)
    8687        ((%dict->alist-ref dict) (%dict-data-ref dict)) )
    8788
    88 (define (%dict-ref dict key def)
     89(define-inline (%dict-ref dict key def)
    8990        ((%dict-ref-ref dict) (%dict-data-ref dict) key def) )
    9091
    91 (define (%dict-set! dict key val)
     92(define-inline (%dict-set! dict key val)
    9293        ((%dict-set-ref dict) (%dict-data-ref dict) key val) )
    9394
    94 (define (%dict-delete! dict key)
     95(define-inline (%dict-delete! dict key)
    9596        ((%dict-delete-ref dict) (%dict-data-ref dict) key) )
    9697
    97 (define (%dict-for-each dict proc)
     98(define-inline (%dict-for-each dict proc)
    9899        ((%dict-for-each-ref dict) (%dict-data-ref dict) proc) )
    99100
    100 (define (%dict-merge dict1 dict2)
     101(define-inline (%dict-merge dict1 dict2)
    101102        ((%dict-merge-ref dict1) (%dict-data-ref dict1) (%dict-data-ref dict2)) )
    102103
    103 (define (%dict-search dict proc def)
     104(define-inline (%dict-search dict proc def)
    104105        ((%dict-search-ref dict) (%dict-data-ref dict) proc def) )
    105106
    106 (define (%dict-count dict)
     107(define-inline (%dict-count dict)
    107108        ((%dict-count-ref dict) (%dict-data-ref dict)) )
    108109
    109 (define (%dict-keys dict)
     110(define-inline (%dict-keys dict)
    110111        ((%dict-keys-ref dict) (%dict-data-ref dict)) )
    111112
    112 (define (%dict-values dict)
     113(define-inline (%dict-values dict)
    113114        ((%dict-values-ref dict) (%dict-data-ref dict)) )
    114115
    115 (define (%dict-exists? dict key)
     116(define-inline (%dict-exists? dict key)
    116117        ((%dict-exists-ref dict) (%dict-data-ref dict) key) )
    117118
    118119;;; Alist Dictionary
    119120
    120 (define (%alist-dict-test data)
     121(define-inline (%alist-dict-test data)
    121122        (car data) )
    122123
    123 (define (%alist-dict-alist data)
     124(define-inline (%alist-dict-alist data)
    124125        (cdr data) )
    125126
     
    141142
    142143(define (alist-dict-for-each data proc)
    143         (for-each (lambda (pair) (proc (car pair) (cdr pair))) (%alist-dict-alist data)) )
     144        (for-each (lambda (cell) (proc (car cell) (cdr cell))) (%alist-dict-alist data)) )
    144145
    145146(define (alist-dict-merge data1 data2)
    146147        (let ((test (%alist-dict-test data1)) (al (%alist-dict-alist data1)))
    147148                (for-each
    148                         (lambda (pair) (set! al (alist-update! (car pair) (cdr pair) al test)))
     149                        (lambda (cell) (set! al (alist-update! (car cell) (cdr cell) al test)))
    149150                        (%alist-dict-alist data2))
    150151                (set-cdr! data1 al) ) )
     
    153154        (let loop ((al (%alist-dict-alist data)))
    154155                (if (null? al) def
    155         (let* ((pair (car al))
    156                (val (cdr pair)))
    157             (if (proc (car pair) val) val
     156        (let* ((cell (car al))
     157               (val (cdr cell)))
     158            (if (proc (car cell) val) val
    158159                (loop (cdr al)) ) ) ) ) )
    159160
     
    198199;;; Hash-table Dictionary
    199200
    200 (define (%hash-table-dict-test data)
     201(define-inline (%hash-table-dict-test data)
    201202        (car data) )
    202203
    203 (define (%hash-table-dict-hash-table data)
     204(define-inline (%hash-table-dict-hash-table data)
    204205        (cdr data) )
    205206
     
    301302                (error loc "invalid dictionary" obj)) )
    302303
    303 (define (check-output-port obj loc)
    304   (unless (output-port? obj)
    305     (error loc "invalid output port" obj) ) )
    306 
    307304(define (check-value obj loc)
    308305  (when (eq? *unspecified* obj)
    309306    (error loc "invalid value" obj) ) )
    310307
    311 (define (%dict-print dict)
     308;;
     309
     310(define (*dict-print dict)
    312311  ((rec (print-node-table dict spcr)
    313312    (%dict-for-each dict
     
    321320    dict '()) )
    322321
    323 (define (%dict-update! dict key valu-func updt-func curr loc)
     322(define (*dict-update! dict key valu-func updt-func curr loc)
    324323  (let ((val (updt-func
    325324              (if (not (eq? *unspecified* curr)) curr
    326325                  (let ((val (valu-func)))
    327                     (when *dict-safe-mode*
    328                       (check-value val loc) )
     326                    (when *dict-safe-mode* (check-value val loc))
    329327                    val ) ) ) ) )
    330328    (%dict-set! dict key val)
    331329    val ) )
    332330
    333 ;;;
    334 
    335 (define (*dict-update! dict key valu-func updt-func loc)
     331(define (+dict-update! dict key valu-func updt-func loc)
    336332  (when *dict-safe-mode*
    337333    (check-dict dict loc)
     
    339335    (check-procedure updt-func loc) )
    340336  (let* ((curr (%dict-ref dict key *unspecified*))
    341          (updt (%dict-update! dict key valu-func updt-func curr loc)))
    342     (unless (eq? *unspecified* curr)
    343       (dict-bestfit dict) )
     337         (updt (*dict-update! dict key valu-func updt-func curr loc)))
     338    (unless (eq? *unspecified* curr) (dict-bestfit dict))
    344339    updt ) )
    345340
    346341;;; Globals
    347342
    348 (define-parameter dict-safe-mode
    349   *dict-safe-mode*
     343(define-parameter dict-safe-mode *dict-safe-mode*
    350344  (lambda (x)
    351345    (set! *dict-safe-mode* x)
     
    413407
    414408(define (dict-update! dict key valu-func #!optional (updt-func identity))
    415         (*dict-update! dict key valu-func updt-func 'dict-update!) )
     409        (+dict-update! dict key valu-func updt-func 'dict-update!) )
    416410
    417411(define (dict-update-list! dict key . vals)
    418   (*dict-update! dict key (lambda () '()) (cut fold cons <> (reverse! vals)) 'dict-update-list!) )
     412  (+dict-update! dict key (lambda () '()) (cut fold cons <> (reverse! vals)) 'dict-update-list!) )
    419413
    420414(define (dict-update-dict! dict key)
    421   (*dict-update! dict key (cut make-dict) identity 'dict-update-dict!) )
     415  (+dict-update! dict key (cut make-dict) identity 'dict-update-dict!) )
    422416
    423417(define (dict-delete! dict key)
     
    454448
    455449(define (dict-print dict #!optional port)
    456   (if (not port) (%dict-print dict)
    457       (begin
    458         (when *dict-safe-mode*
    459           (check-output-port port 'dict-print) )
    460         (with-output-to-port port (lambda () (%dict-print dict)) ) ) ) )
     450  (if (not port) (*dict-print dict)
     451      (with-output-to-port port (lambda () (*dict-print dict)) ) ) )
Note: See TracChangeset for help on using the changeset viewer.