ADDED configf-testing/Makefile Index: configf-testing/Makefile ================================================================== --- /dev/null +++ configf-testing/Makefile @@ -0,0 +1,7 @@ + +%.o : %.scm + csc -J -c $< -o $*.o + +c : c.o a.o + csc a.o c.o -o c + ADDED configf-testing/a.scm Index: configf-testing/a.scm ================================================================== --- /dev/null +++ configf-testing/a.scm @@ -0,0 +1,22 @@ +(declare (unit a)) + +(module a + * + + (import scheme chicken posix) + + (define (a:normalize-dir d) + (if (and (file-exists? d) + (directory? d)) + (let ((curr (current-directory))) + (change-directory d) + (let ((nd (current-directory))) + (change-directory curr) + nd)) + d)) + + ) + + + + Index: configf-testing/c.scm ================================================================== --- configf-testing/c.scm +++ configf-testing/c.scm @@ -1,17 +1,23 @@ +(declare (uses a)) + ;; pretend to be a config file processor (use posix srfi-69) ;; (define getenv get-environment-variable) (define (print-hash-table ht) - (print "ht=" (hash-table->alist ht))) + (print "ht=") + (pp (hash-table->alist ht))) (define cfgdata (conc "(use simple-md5)" + "(import a)" "(set! getenv get-environment-variable)" "(hash-table-set! ht \"PATH\" (getenv \"PATH\"))" "(hash-table-set! ht \"currdir\" (current-directory))" - "(hash-table-set! ht \"md5sum\" (string->md5sum \"Hello\"))")) + "(hash-table-set! ht \"md5sum\" (string->md5sum \"Hello\"))" + ;; in mtconfigf the below is not working + "(hash-table-set! ht \"var-tmp\" (a:normalize-dir \"/var/tmp\"))")) (define (faux-cfg-processor ht cfgdata) (let* ((proc-str (conc "(lambda (ht)" cfgdata ")"))) (with-input-from-string proc-str (lambda () @@ -28,10 +34,14 @@ (lambda () ((eval (read)) ht))))) ) (import cfgprocessor) +(import a) + +(print "\nCan I run stuff from module \"a\":") +(print (a:normalize-dir "/var/tmp")) (print "\nRun the non-modularized version") (let ((ht (make-hash-table))) (faux-cfg-processor ht cfgdata) (print-hash-table ht))