Changeset 10951 in project


Ignore:
Timestamp:
05/29/08 09:55:11 (13 years ago)
Author:
felix winkelmann
Message:

checking of refs to undefd identifiers in modules

Location:
chicken/branches/hygienic
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • chicken/branches/hygienic/TODO

    r10943 r10951  
    22
    33* bugs
    4 ** macro expansion
    5 *** canonicalization of body has to keep track of introduced bindings
    6     or global macros will apply to local bodies that shadow global id locally:
    7     (define-syntax foo ...)
    8     (let () (define (foo) 1) (foo)) ; last expr uses foo macro
    9 **** partially implemented (but not for local syntax bindings)
    104** modules
     5*** exported macros do not inherit local se
     6    and are thus unhygienic and require the importing context to import dependencies
    117*** code-duplication in compiler and evaluator for ##core#module
    128*** syntax-definitions in modules
     
    3733** allow exporting all definitions
    3834** "define-for-syntax" still right?
    39 ** Jim suggests issuing warnings for refs to unimported ids inside modules
    4035
    4136* csi
     
    5651** simple-macros
    5752** alexpander
     53
     54* more bugs
     55** macro expansion
     56*** canonicalization of body has to keep track of introduced bindings
     57    or global macros will apply to local bodies that shadow global id locally:
     58    (define-syntax foo ...)
     59    (let () (define (foo) 1) (foo)) ; last expr uses foo macro
     60**** partially implemented (but not for local syntax bindings)
  • chicken/branches/hygienic/compiler.scm

    r10939 r10951  
    500500                     (finish-foreign-result ft body)
    501501                     t) ) ) ]
    502             ((not (assq x0 se)) (##sys#alias-global-hook x)) ; only globals
     502            ((not (assq x0 se)) (##sys#alias-global-hook x #f)) ; only globals
    503503            (else x))))
    504504 
     
    804804                                [val (walk (caddr x) se var0)] )
    805805                           (when (eq? var var0) ; global?
    806                              (set! var (##sys#alias-global-hook var))
     806                             (set! var (##sys#alias-global-hook var #t))
    807807                             (when safe-globals-flag
    808808                               (set! always-bound-to-procedure
  • chicken/branches/hygienic/eval.scm

    r10939 r10951  
    295295               (receive (i j) (lookup x e se)
    296296                 (cond [(not i)
    297                         (let ((var (##sys#alias-global-hook j)))
     297                        (let ((var (##sys#alias-global-hook j #f)))
    298298                          (if ##sys#eval-environment
    299299                              (let ([loc (##sys#hash-table-location ##sys#eval-environment var #t)])
     
    403403                              (let ((val (compile (caddr x) e var tf cntr se)))
    404404                                (cond [(not i)
    405                                        (let ((var (##sys#alias-global-hook j)))
     405                                       (let ((var (##sys#alias-global-hook j #t)))
    406406                                         (if ##sys#eval-environment
    407407                                             (let ([loc (##sys#hash-table-location
  • chicken/branches/hygienic/expand.scm

    r10943 r10951  
    224224    (##sys#slot sym 1) ) ) )
    225225
    226 (define (##sys#alias-global-hook sym)
     226(define (##sys#alias-global-hook sym assign)
    227227  (define (mrename sym)
    228228    (cond ((##sys#current-module) =>
    229229           (lambda (mod)
    230230             (d "global alias " sym " -> " (module-name mod))
     231             (unless assign (##sys#register-undefined sym mod))
    231232             (##sys#module-rename sym (module-name mod))))
    232233          (else sym)))
     
    11421143
    11431144(define-record-type module
    1144   (make-module name export-list defined-list vexports sexports)
     1145  (make-module name export-list defined-list undefined-list vexports sexports)
    11451146  module?
    11461147  (name module-name)                    ; SYMBOL
    11471148  (export-list module-export-list)      ; (SYMBOL | (SYMBOL ...) ...)
    11481149  (defined-list module-defined-list set-module-defined-list!) ; ((SYMBOL . VALUE) ...)
     1150  (undefined-list module-undefined-list set-module-undefined-list!) ; (SYMBOL ...)
    11491151  (vexports module-vexports set-module-vexports!)             ; (SYMBOL . SYMBOL)
    11501152  (sexports module-sexports set-module-sexports!) )           ; ((SYMBOL SE TRANSFORMER) ...)
     
    11591161(define (##sys#register-export sym mod #!optional val)
    11601162  (when mod
    1161     (let ((exp (##sys#find-export sym mod)))
    1162       (##sys#toplevel-definition-hook (##sys#module-rename sym (module-name mod)) mod exp val)
     1163    (let ((exp (##sys#find-export sym mod))
     1164          (ulist (module-undefined-list mod)))
     1165      (##sys#toplevel-definition-hook
     1166       (##sys#module-rename sym (module-name mod))
     1167       mod exp val)
     1168      (when (memq sym ulist)
     1169        (set-module-undefined-list! mod (##sys#delq sym ulist)))
    11631170      (when exp
    11641171        (d "defined: " sym)
     
    11721179               (module-defined-list mod)))))) )
    11731180
     1181(define (##sys#register-undefined sym mod)
     1182  (when mod
     1183    (let ((ul (module-undefined-list mod)))
     1184      (unless (memq sym ul)
     1185        (set-module-undefined-list! mod (cons sym ul))))))
     1186
    11741187(define (##sys#register-module name explist #!optional (vexports '()) (sexports '()))
    1175   (let ((mod (make-module name explist '() vexports sexports)))
     1188  (let ((mod (make-module name explist '() '() vexports sexports)))
    11761189    (set! ##sys#module-table (cons (cons name mod) ##sys#module-table))
    11771190    mod) )
     
    11931206(define (##sys#register-compiled-module name vexports sexports)
    11941207  (let ((mod (make-module
    1195               name '() '()
     1208              name '() '() '()
    11961209              vexports
    11971210              (map (lambda (se)
     
    12041217  (let* ((me (##sys#macro-environment))
    12051218         (mod (make-module
    1206               name '() '()
     1219              name '() '() '()
    12071220              (map (lambda (ve)
    12081221                     (if (symbol? ve)
     
    12551268         (##sys#warn "exported identifier has not been defined" (car x) name)))
    12561269     vexports)
     1270    (for-each
     1271     (lambda (u)
     1272       (unless (assq u dlist)
     1273         (##sys#warn
     1274          (string-append
     1275           "reference to possible unbound identifier `"
     1276           (##sys#symbol->string u)
     1277           "'"))))
     1278     (module-undefined-list mod))
    12571279    (d `(EXPORTS: ,(module-name mod) ,(map car dlist)
    12581280                  ,(map car vexports) ,(map car sexports)))
  • chicken/branches/hygienic/extras.scm

    r10909 r10951  
    7373
    7474(include "unsafe-declarations.scm")
    75 
    76 (cond-expand
    77  ((not unsafe)
    78   (declare (emit-exports "extras.exports")) )
    79  (else))
    8075
    8176(register-feature! 'extras)
  • chicken/branches/hygienic/private-namespace.scm

    r10712 r10951  
    6262
    6363(set! ##sys#alias-global-hook
    64   (lambda (var)
     64  (lambda (var . assign)                ; must work with old chicken
    6565    (or (get var 'c:namespace) var) ) )
Note: See TracChangeset for help on using the changeset viewer.