Changeset 36820 in project


Ignore:
Timestamp:
11/12/18 00:32:58 (4 weeks ago)
Author:
kon
Message:

simplify sym tbl search

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/5/apropos/trunk/symbol-environment-access.scm

    r36298 r36820  
    3030;;;
    3131
     32;opaque
     33(define-type macro-environment *)
     34
     35;;
     36
     37(define-inline (cons-if test? x xs) (if (test? x) (cons x xs) xs))
     38
     39;;;
     40
    3241;;
    3342
     
    3847;;
    3948
     49(: macro-symbol-in-environment? ((or boolean symbol) (or boolean macro-environment) -> boolean))
     50;
    4051(define (macro-symbol-in-environment? sym macenv)
    4152  (and sym macenv (##sys#macro? sym macenv)) )
     
    4354;;
    4455
     56(: search-list-environment-symbols (list procedure --> list))
     57;
     58(define (search-list-environment-symbols env test?)
     59  (foldl (lambda (syms cell) (cons-if test? (car cell) syms)) '() env) )
     60
    4561(: search-interaction-environment-symbols (* procedure --> list))
    4662;
    47 (define (search-interaction-environment-symbols env optarg?)
     63(define (search-interaction-environment-symbols env test?)
    4864  (let loop ((cursor (cursor-first)) (syms '()))
    4965    (let ((sym (cursor-current cursor)))
    5066      (if (not sym)
    5167        syms
    52         (let ((syms (if (optarg? sym) (cons sym syms) syms)))
    53           (loop (cursor-next cursor) syms) ) ) ) ) )
     68        (loop (cursor-next cursor) (cons-if test? sym syms)) ) ) ) )
    5469
    55 (: search-list-environment-symbols (list procedure --> list))
    56 ;
    57 (define (search-list-environment-symbols env optarg?)
    58   (foldl
    59     (lambda (syms cell)
    60       (let ((sym (car cell)))
    61         (if (optarg? sym)
    62           (cons sym syms)
    63           syms ) ) )
    64     '()
    65     env) )
     70;;
    6671
    6772(: search-macro-environment-symbols (list procedure --> list))
    6873;
    69 (define (search-macro-environment-symbols env optarg?)
    70   (search-list-environment-symbols env optarg?) )
     74(define (search-macro-environment-symbols env test?)
     75  (search-list-environment-symbols env test?) )
    7176
    7277(: search-system-environment-symbols (list procedure --> list))
    7378;
    74 (define (search-system-environment-symbols env optarg?)
     79(define (search-system-environment-symbols env test?)
    7580  (if env
    76     (search-list-environment-symbols env optarg?)
    77     (search-interaction-environment-symbols env optarg?) ) )
     81    (search-list-environment-symbols env test?)
     82    (search-interaction-environment-symbols env test?) ) )
    7883
    7984) ;module symbol-environment-access
Note: See TracChangeset for help on using the changeset viewer.