From: Timothy H. <tim...@ma...> - 2003-03-07 16:52:48
|
On Friday, March 7, 2003, at 11:15 AM, Ken Anderson wrote: > Some questions about modules. > > ? is there a way to export symbols? Currently, everything is exported.... > For example, in the elf/future.scm i wanted to export future, future?, > determined?, touch, and i wanted to have the other procedures not show > up in the user's environment. > > Rather than loading a module and seeing the exported symbols, i have to > explictly import it with a prefix say, "f:". or you can import everything without a prefix ... > Then i either have to say > (f:future x) or > (define future f:future) The current implementation allows either a prefixed importation (environment-import "abc.scm" "f:") or a non-prefixed import (environment-import "abc.scm") There is currently no way to import only a selected subset or to export a selected subset... Actually, you can "hack" export using set!, The set! makes the assignment occur in the toplevel environment and the (let () ...) hides all the other assignments ... > ( > (let () ;;; define future, future? etc inside a let() environment > (define (future x) ...) > (define (future? x) ...) > ... > (list future future? ...)) > > (lambda R ;;; use set! to lift these definitions to the global > environment > (set! future (first R)) > (set! future? (second R)) > ...) > ) We could easily write a little macro which implements this style of export: > (export (future future? ...) > (define (future x) ...) > (define (future? x) ...) > ... > ) > Similarly, we could wriite a macro to import just a few values from a file > (import "elf/future.scm" (future future? ...)) which could expand to > (import "elf/future.scm" "HIDDEN:") > (define future HIDDEN:future) > (define future? HIDDEN:future?) > ... Other variations could be implemented as well (import-all-but ....) etc. ---Tim--- |