diff --git a/src/t.scm b/src/t.scm index 6242904..8f9310d 100644 --- a/src/t.scm +++ b/src/t.scm @@ -808,12 +808,12 @@ (loop (cdr files) (cons wrapped-sexps exp-lists))))))) ; return the right ce branch using (lit=? id sym) for literal match -(define (preprocess-cond-expand lit=? sexp) ;=> (sexp ...) +(define (preprocess-cond-expand lit=? sexp env) ;=> (sexp ...) (define (pp freq con alt) (cond [(lit=? freq 'else) (con)] [(id? freq) (if (feature-available? (id->sym freq)) (con) (alt))] [(and (list2? freq) (lit=? (car freq) 'library)) - (if (library-available? (xform-sexp->datum (cadr freq))) (con) (alt))] + (if (library-available? (xform-sexp->datum (cadr freq)) env) (con) (alt))] [(and (list1+? freq) (lit=? (car freq) 'and)) (cond [(null? (cdr freq)) (con)] [(null? (cddr freq)) (pp (cadr freq) con alt)] [else (pp (cadr freq) (lambda () (pp (cons (car freq) (cddr freq)) con alt)) alt)])] @@ -831,7 +831,7 @@ (lambda (sexp env) (define (lit=? id sym) ; match literal using free-id=? -like match (and (id? id) (eq? (xenv-ref env id) (xenv-ref root-environment sym)))) - (cons begin-id (preprocess-cond-expand lit=? sexp)))) + (cons begin-id (preprocess-cond-expand lit=? sexp env)))) ; library transformers @@ -965,7 +965,7 @@ (loop (append (cdr decl) decls) code eal esps forms)] [(eq? (car decl) ld-cond-expand-id) ; flatten and splice (let ([lit=? (lambda (id sym) (and (id? id) (eq? id (id-rename-as sid sym))))]) - (loop (append (preprocess-cond-expand lit=? (cdr decl)) decls) code eal esps forms))] + (loop (append (preprocess-cond-expand lit=? (cdr decl)) decls env) code eal esps forms))] [(eq? (car decl) ld-push-cf-id) ; internal (check-syntax decl '( ) "invalid library declarations syntax") (push-current-file! (cadr decl)) @@ -1025,13 +1025,25 @@ [(eq? hval 'define-syntax) (let* ([core (xform-define-syntax tail cenv)] [loc (xenv-lookup cenv (cadr core) 'define-syntax)]) - (unless (location? loc) (x-error "unexpected define-syntax for id" (cadr core) first)) + (unless (location? loc) + (x-error "unexpected define-syntax for id" (cadr core) first)) (location-set-val! loc (caddr core)) (scan rest code*))] [(eq? hval 'define-library) - (x-error "NYI: define-library inside library code" first)] - [(eq? hval 'import) - (x-error "NYI: import inside library code" first)] + (let* ([core (xform-define-library head tail env #f)] + ; core is (define-library ) + [loc (xenv-lookup env (cadr core) 'define-syntax)]) + (unless (location? loc) + (x-error "unexpected define-library for id" (cadr core) first)) + (location-set-val! loc (caddr core)) + (scan rest code*))] + [(eq? hval 'import) ; support, in case there is an internal import + (let* ([core (xform-import head tail cenv #f)] + ; core is (import ) + [l (cadr core)] [code (library-code l)] [eal (library-exports l)]) + (unless (cenv eal 'import) ; adjoins eal to cenv's imports + (x-error "broken import inside library code" first)) + (scan rest (cons code code*)))] ; adds library init code ; TODO: check for built-in (export) and modify eal! [(val-transformer? hval) ; apply transformer and loop (scan (cons (hval first cenv) rest) code*)] @@ -1679,10 +1691,10 @@ (when ci? (set-port-fold-case! port #t)) (read-port-sexps port)))) -(define (library-available? lib) ;=> #f | filepath (external) | (code . eal) (loaded) +(define (library-available? lib env) ;=> #f | filepath (external) | (code . eal) (loaded) (cond [(string? lib) (file-resolve-relative-to-current lib)] - [(library-info lib #f)] ; builtin or preloaded - [else (and (list1+? lib) (find-library-path lib))])) ;(or (symbol? lib) (list1+? lib)) + [(library-info lib #f)] ; builtin or preloaded FIXME: need to take env into account! + [else (and (listname? lib) (find-library-path lib))])) ; name prefixes @@ -1706,6 +1718,9 @@ (define (eal->name-registry eal) (vector eal '())) +(define (eal-name-registry-import! ir ial) + (vector-set! ir 0 (adjoin-eals (vector-ref ir 0) ial))) ; may end in x-error on conflict + (define (name-lookup nr name mkdefval) ;=> loc | #f (let* ([n-1 (- (vector-length nr) 1)] [i (if (pair? name) n-1 (immediate-hash name n-1))] [al (vector-ref nr i)] [p (if (pair? name) (assoc name al) (assq name al))]) @@ -1916,6 +1931,14 @@ (lambda (n) ; not in lr: check ir and fail if it's there (and (not (name-lookup ir name #f)) ; not imported? alloc: (void))))] + [(and (eq? at 'import) (sexp-match? '(( . #&*) ...) name)) + ; someone trues to add new imports: allow if there are no conflicts + (let ([ial name]) + (define (check p) + (cond [(name-lookup lr (car p) #f) => (lambda (loc) + (x-error "imported name shadows local name" (car p) (cdr p) loc))])) + (for-each check ial) + (eal-name-registry-import! ir ial))] [else #f]))) ; mutable environment from two registries; new bindings go to user registry @@ -2007,38 +2030,33 @@ (cadr core) env)))] [(eq? hval 'define-syntax) ; use new protocol for top-level envs (let* ([core (xform-define-syntax (cdr x) env)] + ; core is (define-syntax ) [loc (xenv-lookup env (cadr core) 'define-syntax)]) - (if loc ; location or #f - (location-set-val! loc (caddr core)) - (x-error "identifier cannot be (re)defined as syntax in env:" - (cadr core) env)) + (unless (location? loc) + (x-error "unexpected define-syntax for id" (cadr core) x)) + (location-set-val! loc (caddr core)) (when *verbose* (display "SYNTAX INSTALLED: ") (write (cadr core)) (newline)))] [(eq? hval 'define-library) ; use new protocol for top-level envs (let* ([core (xform-define-library (car x) (cdr x) env #t)] + ; core is (define-library ) [loc (xenv-lookup env (cadr core) 'define-syntax)]) - (if loc ; location or #f - (let ([l (caddr core)]) (location-set-val! loc l)) - (x-error "identifier cannot be (re)defined as syntax in env:" - (cadr core) env)) + (unless (location? loc) + (x-error "unexpected define-library for id" (cadr core) x)) + (location-set-val! loc (caddr core)) (when *verbose* (display "LIBRARY INSTALLED: ") (write (cadr core)) (newline)))] [(eq? hval 'import) ; splice as definitions - (let* ([core (xform-import (car x) (cdr x) env #t)] ; core is (import ) + (let* ([core (xform-import (car x) (cdr x) env #t)] + ; core is (import ) [l (cadr core)] [code (library-code l)] [eal (library-exports l)]) - ; note: we should somehow introduce imported locations as-is for keywords like - ; 'else' to work correctly -- while protecting imported locations from change - ; via define or define-syntax; lookup with at=define-syntax returns us new - ; location from user name registry, offering different locations and no protection! - ; we need to extend env protocol, e.g. (env id ) that either fails, - ; or inserts under id where it will be returned via (env id 'ref) - ; and nothing else. We use (env eal 'import) -- with guarantees that env can't - ; answer any requests but 'ref to imported bindings - (let ([counts (env eal 'import)]) ; manually invoke env's extended behavior - (if (sexp-match? '( ) counts) - (when *verbose* (display "IMPORT: ") - (write (car counts)) (display " bindings are the same, ") - (write (cadr counts)) (display " modified, ") - (write (caddr counts)) (display " added\n")) - (x-error "failed to import to env, import is not supported:" env eal))) + ; note: try to use env's import protocol + (let ([res (env eal 'import)]) + (unless res ; this env does not support import + (x-error "failed to import to env, import is not supported:" env eal)) + (when (and *verbose* (sexp-match? '( ) res)) + (display "IMPORT: ") + (write (car res)) (display " bindings are the same, ") + (write (cadr res)) (display " modified, ") + (write (caddr res)) (display " added\n"))) (repl-compile-and-run-core-expr code))] [(val-transformer? hval) ; apply transformer and loop (repl-eval-top-form (hval x env) env)] diff --git a/t.c b/t.c index 5516d79..2259bc5 100644 --- a/t.c +++ b/t.c @@ -476,24 +476,24 @@ char *t_code[] = { "exps)[02},n,n,:2^cc,.1L6,n,.5c,:3^cc,.6,.1c,.6d,:1^[72}.!0.0^_1[22}]5", "P", "preprocess-cond-expand", - "%2,#0.0,.2,&2{%3${'(y4:else),.3,:0[02}?{.1[30}${.2,@(y3:id?)[01}?{${${" - ".4,@(y7:id->sym)[01},@(y18:feature-available?)[01}?{.1[30}.2[30}${.2,@" - "(y6:list2?)[01}?{${'(y7:library),.3a,:0[02}}{f}?{${${.4da,@(y17:xform-" - "sexp->datum)[01},@(y18:library-available?)[01}?{.1[30}.2[30}${.2,@(y7:" - "list1+?)[01}?{${'(y3:and),.3a,:0[02}}{f}?{.0du?{.1[30}.0ddu?{.2,.2,.2d" - "a,:1^[33}.2,.3,.3,.3,:1,&4{%0:3,:2,:1dd,:1ac,:0^[03},.2da,:1^[33}${.2," - "@(y7:list1+?)[01}?{${'(y2:or),.3a,:0[02}}{f}?{.0du?{.2[30}.0ddu?{.2,.2" - ",.2da,:1^[33}.2,.2,.2,:1,&4{%0:3,:2,:1dd,:1ac,:0^[03},.2,.2da,:1^[33}$" - "{.2,@(y6:list2?)[01}?{${'(y3:not),.3a,:0[02}}{f}?{.1,.3,.2da,:1^[33}.0" - ",'(s39:invalid cond-expand feature requirement),@(y7:x-error)[32}.!0${" - "'(s26:invalid cond-expand syntax),'(l3:y4:;l3:y1:*;y1:*;y3:...;;y3" - ":...;),.6,@(y12:check-syntax)[03}.2d,,#0.0,.3,&2{%1.0u?{n]1}.0,:1,&2{%" - "0:1d,:0^[01},.1,&1{%0:0ad]0},.2aa,:0^[13}.!0.0^_1[31", + "%3,#0.0,.2,.5,&3{%3${'(y4:else),.3,:1[02}?{.1[30}${.2,@(y3:id?)[01}?{$" + "{${.4,@(y7:id->sym)[01},@(y18:feature-available?)[01}?{.1[30}.2[30}${." + "2,@(y6:list2?)[01}?{${'(y7:library),.3a,:1[02}}{f}?{${:0,${.5da,@(y17:" + "xform-sexp->datum)[01},@(y18:library-available?)[02}?{.1[30}.2[30}${.2" + ",@(y7:list1+?)[01}?{${'(y3:and),.3a,:1[02}}{f}?{.0du?{.1[30}.0ddu?{.2," + ".2,.2da,:2^[33}.2,.3,.3,.3,:2,&4{%0:3,:2,:1dd,:1ac,:0^[03},.2da,:2^[33" + "}${.2,@(y7:list1+?)[01}?{${'(y2:or),.3a,:1[02}}{f}?{.0du?{.2[30}.0ddu?" + "{.2,.2,.2da,:2^[33}.2,.2,.2,:2,&4{%0:3,:2,:1dd,:1ac,:0^[03},.2,.2da,:2" + "^[33}${.2,@(y6:list2?)[01}?{${'(y3:not),.3a,:1[02}}{f}?{.1,.3,.2da,:2^" + "[33}.0,'(s39:invalid cond-expand feature requirement),@(y7:x-error)[32" + "}.!0${'(s26:invalid cond-expand syntax),'(l3:y4:;l3:y1:*;y1:*;y3:." + "..;;y3:...;),.6,@(y12:check-syntax)[03}.2d,,#0.0,.3,&2{%1.0u?{n]1}.0,:" + "1,&2{%0:1d,:0^[01},.1,&1{%0:0ad]0},.2aa,:0^[13}.!0.0^_1[41", "P", "make-cond-expand-transformer", "%0&0{%2,#0.2,&1{%2${.2,@(y3:id?)[01}?{${.3,@(y16:root-environment),@(y" - "8:xenv-ref)[02},${.3,:0,@(y8:xenv-ref)[02}q]2}f]2}.!0${.3,.3^,@(y22:pr" - "eprocess-cond-expand)[02},@(y8:begin-id)c]3}]0", + "8:xenv-ref)[02},${.3,:0,@(y8:xenv-ref)[02}q]2}f]2}.!0${.4,.4,.4^,@(y22" + ":preprocess-cond-expand)[03},@(y8:begin-id)c]3}]0", "P", "adjoin-code", "%2'(l1:y5:begin;),.1e?{.1]2}'(l1:y5:begin;),.2e?{.0]2}${.2,'(l3:y5:beg" @@ -562,34 +562,34 @@ char *t_code[] = { "?)[02}?{:0,.1aaq}{f}?{${.3,${.5adda,@(y7:id->sym)[01},${.6ada,@(y7:id-" ">sym)[01}c,l1,@(y11:adjoin-esps)[02},.1d,:1^[22}${.2a,@(y17:xform-sexp" "->datum)[01},'(s27:invalid export spec element),@(y7:x-error)[22}.!0n," - "n,n,'(l1:y5:begin;),.(i19)d,,#0.(i19),.7,.(i20),.(i25),.(i14),.(i18),." - "(i26),.(i16),.(i29),.(i21),.(i21),.(i28),.(i20),.(i29),.(i21),.(i30),." + "n,n,'(l1:y5:begin;),.(i19)d,,#0.(i19),.7,.(i20),.(i13),.(i17),.(i25),." + "(i28),.(i16),.(i29),.(i21),.(i21),.(i28),.(i20),.(i29),.(i21),.(i30),." "(i16),&(i17){%5.0u?{.4,.4,.4,.4,l4]5}.0d,.1a,:(i16),.1aq?{.6,${.8,${n," ".7d,:(i15)^[02},@(y11:adjoin-esps)[02},.6,.6,.5,:0^[75}${.2,@(y6:list2" "?)[01}?{:(i14),.1aq?{:(i14),.1daq}{f}}{f}?{@(y18:import-transformer)b," "'(y6:import)c,l1,.7,.7,${.9,.5,@(y11:adjoin-eals)[02},.7,.6,:0^[85}:(i" - "14),.1aq?{${:(i13),.3,@(y22:preprocess-import-sets)[02},.0d,.1a,.9,.9," + "14),.1aq?{${:(i10),.3,@(y22:preprocess-import-sets)[02},.0d,.1a,.9,.9," "${.(i11),.6,@(y11:adjoin-eals)[02},${.5,.(i12),@(y11:adjoin-code)[02}," - ".8,:0^[(i10)5}:(i12),.1aq?{.6,.6,.6,.6,.5,.5dL6,:0^[75}:(i11),.1aq?{:(" - "i10),&1{%2${.2,@(y3:id?)[01}?{${.3,:0,@(y12:id-rename-as)[02},.1q]2}f]" - "2},.7,.7,.7,.7,.6,${.8d,.8,@(y22:preprocess-cond-expand)[02}L6,:0^[85}" - ":7,.1aq?{${'(s35:invalid library declarations syntax),'(l2:y4:;y8:" - ";),.4,@(y12:check-syntax)[03}${.2da,@(y18:push-current-file!)[" - "01}.6,.6,.6,.6,.5,:0^[75}:6,.1aq?{${'(s35:invalid library declarations" - " syntax),'(l1:y4:;),.4,@(y12:check-syntax)[03}${@(y17:pop-current-" - "file!)[00}.6,.6,.6,.6,.5,:0^[75}:9,.1aq?{${'(s43:invalid include-libra" - "ry-declarations syntax),'(l3:y4:;y8:;y3:...;),.4,@(y12:che" - "ck-syntax)[03}.1,.1dA8,,#0:8,:7,:6,.3,:0,.(i11),.(i13),.(i15),.(i17),&" - "9{%2.0u?{:0,:1,:2,:3,.5,:4^[25}${.2a,@(y32:file-resolve-relative-to-cu" - "rrent)[01},.0S0?{.0F0}{f},.0?{t}{${:8,.5a,'(s27:cannot include declara" - "tions),@(y7:x-error)[03}},${f,.5,@(y15:read-file-sexps)[02},.5,n,:6cc," - ".1L6,n,.5c,:7cc,.5d,:5^[62}.!0.0^_1[72}:5,.1aq?{${'(s42:invalid includ" - "e library declaration syntax),'(l3:y4:;y8:;y3:...;),.4,@(y" - "12:check-syntax)[03}n,.1d,:4cc,.7L6,.6,.6,.6,.5,:0^[75}:3,.1aq?{${'(s4" - "5:invalid include-ci library declaration syntax),'(l3:y4:;y8:;y3:...;),.4,@(y12:check-syntax)[03}n,.1d,:2cc,.7L6,.6,.6,.6,.5,:0^" - "[75}:1,.1aq?{${.2d,@(y17:xform-sexp->datum)[01},.7L6,.6,.6,.6,.5,:0^[7" - "5}f]7}.!0.0^_1[(i17)5", + ".8,:0^[(i10)5}:(i13),.1aq?{.6,.6,.6,.6,.5,.5dL6,:0^[75}:(i12),.1aq?{:(" + "i11),&1{%2${.2,@(y3:id?)[01}?{${.3,:0,@(y12:id-rename-as)[02},.1q]2}f]" + "2},.7,.7,.7,.7,:(i10),.7L6,${.8d,.8,@(y22:preprocess-cond-expand)[02}L" + "6,:0^[85}:7,.1aq?{${'(s35:invalid library declarations syntax),'(l2:y4" + ":;y8:;),.4,@(y12:check-syntax)[03}${.2da,@(y18:push-curren" + "t-file!)[01}.6,.6,.6,.6,.5,:0^[75}:6,.1aq?{${'(s35:invalid library dec" + "larations syntax),'(l1:y4:;),.4,@(y12:check-syntax)[03}${@(y17:pop" + "-current-file!)[00}.6,.6,.6,.6,.5,:0^[75}:9,.1aq?{${'(s43:invalid incl" + "ude-library-declarations syntax),'(l3:y4:;y8:;y3:...;),.4," + "@(y12:check-syntax)[03}.1,.1dA8,,#0:8,:7,:6,.3,:0,.(i11),.(i13),.(i15)" + ",.(i17),&9{%2.0u?{:0,:1,:2,:3,.5,:4^[25}${.2a,@(y32:file-resolve-relat" + "ive-to-current)[01},.0S0?{.0F0}{f},.0?{t}{${:8,.5a,'(s27:cannot includ" + "e declarations),@(y7:x-error)[03}},${f,.5,@(y15:read-file-sexps)[02},." + "5,n,:6cc,.1L6,n,.5c,:7cc,.5d,:5^[62}.!0.0^_1[72}:5,.1aq?{${'(s42:inval" + "id include library declaration syntax),'(l3:y4:;y8:;y3:..." + ";),.4,@(y12:check-syntax)[03}n,.1d,:4cc,.7L6,.6,.6,.6,.5,:0^[75}:3,.1a" + "q?{${'(s45:invalid include-ci library declaration syntax),'(l3:y4:" + ";y8:;y3:...;),.4,@(y12:check-syntax)[03}n,.1d,:2cc,.7L6,.6,.6," + ".6,.5,:0^[75}:1,.1aq?{${.2d,@(y17:xform-sexp->datum)[01},.7L6,.6,.6,.6" + ",.5,:0^[75}f]7}.!0.0^_1[(i17)5", "P", "preprocess-library", "%2,#0.1,&1{%1${:0,@(y7:list2+?)[01}?{${:0da,@(y3:id?)[01}}{f}?{${.2,@(" @@ -599,27 +599,31 @@ char *t_code[] = { "03}${.3,@(y7:list2+?)[01}?{${.3da,@(y3:id?)[01}}{f}?{${.3da,@(y7:id->s" "ym)[01}}{f},.0?{.2dd}{.2d},${.6,.3,.7ac,@(y31:preprocess-library-decla" "rations)[02},.0a,.1da,.2dda,.3ddda,${.(i11),.(i10)^,.6,@(y27:make-cont" - "rolled-environment)[03},n,,#0.0,.3,&2{%2.0u?{.1]2}.0d,.1a,.0p?{.0a,.1d" - ",${:0,.4,t,@(y5:xform)[03},'(y5:begin),.1q?{.1L0~?{${.5,'(s19:improper" - " begin form),@(y7:x-error)[02}}.6,.5,.3L6,:1^[72}'(y6:define),.1q?{${." - "3,@(y6:list2?)[01}?{.1au}{f}}{f}?{.6,.5,.3daL6,:1^[72}'(y6:define),.1q" - "?{${:0,.4,@(y12:xform-define)[02},${'(y6:define),.3da,:0,@(y11:xenv-lo" - "okup)[03},.0Y2~?{${.7,.4da,'(s24:unexpected define for id),@(y7:x-erro" - "r)[03}}.8,.2dda,.2zda,'(y4:set!),l3c,.7,:1^[92}'(y13:define-syntax),.1" - "q?{${:0,.4,@(y19:xform-define-syntax)[02},${'(y13:define-syntax),.3da," - ":0,@(y11:xenv-lookup)[03},.0Y2~?{${.7,.4da,'(s31:unexpected define-syn" - "tax for id),@(y7:x-error)[03}}.1dda,.1sz.8,.7,:1^[92}'(y14:define-libr" - "ary),.1q?{.3,'(s39:NYI: define-library inside library code),@(y7:x-err" - "or)[72}'(y6:import),.1q?{.3,'(s31:NYI: import inside library code),@(y" - "7:x-error)[72}.0K0?{.6,.5,${:0,.8,.6[02}c,:1^[72}.0U0?{.6,${:0,.5,.5,@" - "(y16:xform-integrable)[03}c,.5,:1^[72}.6,${:0,.7,f,@(y5:xform)[03}c,.5" - ",:1^[72}.3,${:0,.4,f,@(y5:xform)[03}c,.2,:1^[42}.!0${n,.6,.4^[02},.0A9" - ",'(y5:begin)c,${.(i13)?{.2,.(i14),'(y4:once),l3}{.2},.(i11),@(y11:adjo" - "in-code)[02},.4,.8,,#0.8,.1,.5,&3{%2.0u?{.1A9,:0c]2}.0aa,.1ad,${'(y3:r" - "ef),.4,:2[02},.0~?{.2,'(s16:cannot export id),@(y7:x-error)[52}${.2,@(" - "y17:location-special?)[01}?{.4,.1,.3cc,.4d,:1^[52}.0z,.0p~,.0?{.0}{'(l" - "2:y3:ref;y5:const;),.2aA0}_1?{.5,.2,.4cc,.5d,:1^[62}.0,.4,'(s27:cannot" - " export code alias id),@(y7:x-error)[63}.!0.0^_1[(i16)2", + "rolled-environment)[03},n,,#0.(i12),.1,.4,&3{%2.0u?{.1]2}.0d,.1a,.0p?{" + ".0a,.1d,${:0,.4,t,@(y5:xform)[03},'(y5:begin),.1q?{.1L0~?{${.5,'(s19:i" + "mproper begin form),@(y7:x-error)[02}}.6,.5,.3L6,:1^[72}'(y6:define),." + "1q?{${.3,@(y6:list2?)[01}?{.1au}{f}}{f}?{.6,.5,.3daL6,:1^[72}'(y6:defi" + "ne),.1q?{${:0,.4,@(y12:xform-define)[02},${'(y6:define),.3da,:0,@(y11:" + "xenv-lookup)[03},.0Y2~?{${.7,.4da,'(s24:unexpected define for id),@(y7" + ":x-error)[03}}.8,.2dda,.2zda,'(y4:set!),l3c,.7,:1^[92}'(y13:define-syn" + "tax),.1q?{${:0,.4,@(y19:xform-define-syntax)[02},${'(y13:define-syntax" + "),.3da,:0,@(y11:xenv-lookup)[03},.0Y2~?{${.7,.4da,'(s31:unexpected def" + "ine-syntax for id),@(y7:x-error)[03}}.1dda,.1sz.8,.7,:1^[92}'(y14:defi" + "ne-library),.1q?{${f,:2,.5,.7,@(y20:xform-define-library)[04},${'(y13:" + "define-syntax),.3da,:2,@(y11:xenv-lookup)[03},.0Y2~?{${.7,.4da,'(s32:u" + "nexpected define-library for id),@(y7:x-error)[03}}.1dda,.1sz.8,.7,:1^" + "[92}'(y6:import),.1q?{${f,:0,.5,.7,@(y12:xform-import)[04},.0da,'0,.1V" + "4,'1,.2V4,${'(y6:import),.3,:0[02}~?{${.9,'(s33:broken import inside l" + "ibrary code),@(y7:x-error)[02}}.(i10),.2c,.9,:1^[(i11)2}.0K0?{.6,.5,${" + ":0,.8,.6[02}c,:1^[72}.0U0?{.6,${:0,.5,.5,@(y16:xform-integrable)[03}c," + ".5,:1^[72}.6,${:0,.7,f,@(y5:xform)[03}c,.5,:1^[72}.3,${:0,.4,f,@(y5:xf" + "orm)[03}c,.2,:1^[42}.!0${n,.6,.4^[02},.0A9,'(y5:begin)c,${.(i13)?{.2,." + "(i14),'(y4:once),l3}{.2},.(i11),@(y11:adjoin-code)[02},.4,.8,,#0.8,.1," + ".5,&3{%2.0u?{.1A9,:0c]2}.0aa,.1ad,${'(y3:ref),.4,:2[02},.0~?{.2,'(s16:" + "cannot export id),@(y7:x-error)[52}${.2,@(y17:location-special?)[01}?{" + ".4,.1,.3cc,.4d,:1^[52}.0z,.0p~,.0?{.0}{'(l2:y3:ref;y5:const;),.2aA0}_1" + "?{.5,.2,.4cc,.5d,:1^[62}.0,.4,'(s27:cannot export code alias id),@(y7:" + "x-error)[63}.!0.0^_1[(i16)2", "P", "xform-define-library", "%4${.3,@(y7:list2+?)[01}?{${.3a,@(y9:listname?)[01}}{f}?{${.3a,@(y17:x" @@ -976,9 +980,9 @@ char *t_code[] = { "-input-file)[22", "P", "library-available?", - "%1.0S0?{.0,@(y32:file-resolve-relative-to-current)[11}${f,.3,@(y12:lib" - "rary-info)[02},.0?{.0]2}${.3,@(y7:list1+?)[01}?{.1,@(y17:find-library-" - "path)[21}f]2", + "%2.0S0?{.0,@(y32:file-resolve-relative-to-current)[21}${f,.3,@(y12:lib" + "rary-info)[02},.0?{.0]3}${.3,@(y9:listname?)[01}?{.1,@(y17:find-librar" + "y-path)[31}f]3", "P", "fully-qualified-library-prefixed-name", "%2.1,'(y1:?),.2Y0?{.2}{${.4,@(y16:listname->symbol)[01}},@(y13:symbol-" @@ -994,6 +998,9 @@ char *t_code[] = { "P", "eal->name-registry", "%1n,.1,V12]1", + "P", "eal-name-registry-import!", + "%2${.3,'0,.4V4,@(y11:adjoin-eals)[02},'0,.2V5]2", + "P", "name-lookup", "%3'1,.1V3-,.2p?{.0}{.0,.3H2},.0,.3V4,.4p?{.0,.5A5}{.0,.5A3},.0?{.0d]7}" ".6?{${.7,.9[01},.0~?{f]8}.0Y2?{.0]8}.0b,.3,.1,.9cc,.5,.8V5.0]9}f]7", @@ -1228,7 +1235,11 @@ char *t_code[] = { "0?{.0Y0?{.0,:1,:2,&3{%1${f,:2,:0^,@(y11:name-lookup)[03}~?{${:2,:1[01}" ",'(y3:ref),l2]1}f]1},.1,:3^,@(y11:name-lookup)[23}f]2}'(y13:define-syn" "tax),.2q?{.0,:2,&2{%1${f,:1,:0^,@(y11:name-lookup)[03}~?{Y9]1}f]1},.1," - ":3^,@(y11:name-lookup)[23}f]2}]5", + ":3^,@(y11:name-lookup)[23}'(y6:import),.2q?{${.2,'(l2:py8:;zy1" + ":*;;;y3:...;),@(y11:sexp-match?)[02}}{f}?{.0,,#0:3,&1{%1${f,.3a,:0^,@(" + "y11:name-lookup)[03},.0?{.0,.0,.3d,.4a,'(s32:imported name shadows loc" + "al name),@(y7:x-error)[34}f]2}.!0${.3,.3^,@(y10:%25for-each1)[02}.1,:2" + "^,@(y25:eal-name-registry-import!)[42}f]2}]5", "P", "make-repl-environment", "%3,#0.3,&1{%1.0,:0,@(y37:fully-qualified-library-prefixed-name)[12}.!0" @@ -1275,25 +1286,24 @@ char *t_code[] = { "r)[51}.4,.2da,'(s52:identifier cannot be (re)defined as variable in en" "v:),@(y7:x-error)[53}'(y13:define-syntax),.1q?{${.4,.4d,@(y19:xform-de" "fine-syntax)[02},${'(y13:define-syntax),.3da,.7,@(y11:xenv-lookup)[03}" - ",.0?{.1dda,.1sz}{${.6,.4da,'(s50:identifier cannot be (re)defined as s" - "yntax in env:),@(y7:x-error)[03}}@(y9:*verbose*)?{Po,'(s18:SYNTAX INST" - "ALLED: )W4Po,.2daW5PoW6]5}]5}'(y14:define-library),.1q?{${t,.5,.5d,.6a" - ",@(y20:xform-define-library)[04},${'(y13:define-syntax),.3da,.7,@(y11:" - "xenv-lookup)[03},.0?{.1dda,.0,.2sz_1}{${.6,.4da,'(s50:identifier canno" - "t be (re)defined as syntax in env:),@(y7:x-error)[03}}@(y9:*verbose*)?" - "{Po,'(s19:LIBRARY INSTALLED: )W4Po,.2daW5PoW6]5}]5}'(y6:import),.1q?{$" - "{t,.5,.5d,.6a,@(y12:xform-import)[04},.0da,'0,.1V4,'1,.2V4,${'(y6:impo" - "rt),.3,.(i10)[02},${.2,'(l3:y8:;y8:;y8:;),@(y1" - "1:sexp-match?)[02}?{@(y9:*verbose*)?{Po,'(s8:IMPORT: )W4Po,.1aW5Po,'(s" - "24: bindings are the same, )W4Po,.1daW5Po,'(s11: modified, )W4Po,.1dda" - "W5Po,'(s7: added%0a)W4}}{${.3,.(i10),'(s49:failed to import to env, im" - "port is not supported:),@(y7:x-error)[03}}_1.1,@(y30:repl-compile-and-" - "run-core-expr)[71}.0K0?{.2,${.5,.5,.5[02},@(y18:repl-eval-top-form)[32" - "}.0U0?{${.4,.4d,.4,@(y16:xform-integrable)[03},@(y30:repl-compile-and-" - "run-core-expr)[31}.0Y0?{${.4,.4,f,@(y5:xform)[03},@(y30:repl-compile-a" - "nd-run-core-expr)[31}${.4,.4d,.4,@(y10:xform-call)[03},@(y30:repl-comp" - "ile-and-run-core-expr)[31}${.3,.3,f,@(y5:xform)[03},@(y30:repl-compile" - "-and-run-core-expr)[21", + ",.0Y2~?{${.5,.4da,'(s31:unexpected define-syntax for id),@(y7:x-error)" + "[03}}.1dda,.1sz@(y9:*verbose*)?{Po,'(s18:SYNTAX INSTALLED: )W4Po,.2daW" + "5PoW6]5}]5}'(y14:define-library),.1q?{${t,.5,.5d,.6a,@(y20:xform-defin" + "e-library)[04},${'(y13:define-syntax),.3da,.7,@(y11:xenv-lookup)[03},." + "0Y2~?{${.5,.4da,'(s32:unexpected define-library for id),@(y7:x-error)[" + "03}}.1dda,.1sz@(y9:*verbose*)?{Po,'(s19:LIBRARY INSTALLED: )W4Po,.2daW" + "5PoW6]5}]5}'(y6:import),.1q?{${t,.5,.5d,.6a,@(y12:xform-import)[04},.0" + "da,'0,.1V4,'1,.2V4,${'(y6:import),.3,.(i10)[02},.0~?{${.3,.(i10),'(s49" + ":failed to import to env, import is not supported:),@(y7:x-error)[03}}" + "@(y9:*verbose*)?{${.2,'(l3:y8:;y8:;y8:;),@(y11" + ":sexp-match?)[02}}{f}?{Po,'(s8:IMPORT: )W4Po,.1aW5Po,'(s24: bindings a" + "re the same, )W4Po,.1daW5Po,'(s11: modified, )W4Po,.1ddaW5Po,'(s7: add" + "ed%0a)W4}_1.1,@(y30:repl-compile-and-run-core-expr)[71}.0K0?{.2,${.5,." + "5,.5[02},@(y18:repl-eval-top-form)[32}.0U0?{${.4,.4d,.4,@(y16:xform-in" + "tegrable)[03},@(y30:repl-compile-and-run-core-expr)[31}.0Y0?{${.4,.4,f" + ",@(y5:xform)[03},@(y30:repl-compile-and-run-core-expr)[31}${.4,.4d,.4," + "@(y10:xform-call)[03},@(y30:repl-compile-and-run-core-expr)[31}${.3,.3" + ",f,@(y5:xform)[03},@(y30:repl-compile-and-run-core-expr)[21", "P", "repl-read", "%2.1?{PoW6Po,.2W4Po,'(s1: )W4}.0,@(y14:read-code-sexp)[21",