main 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #! /usr/local/bin/guile -s
  2. !#
  3. ;;; examples/modules/main -- Module system demo.
  4. ;;; Commentary:
  5. ;;; The main demo program for the modules subdirectory.
  6. ;;;
  7. ;;; This program shows how all the new fancy module import features
  8. ;;; are to be used.
  9. ;;; Author: Martin Grabmueller
  10. ;;; Date: 2001-05-29
  11. ;;; Code:
  12. (define-module (main)
  13. ;; The module 0 is imported completely.
  14. ;;
  15. :use-module (module-0)
  16. ;; Module 1 is imported completely, too, but the procedure names are
  17. ;; prefixed with the module name.
  18. ;;
  19. :use-module ((module-1) :renamer (symbol-prefix-proc 'module-1:))
  20. ;; From module 2, only the procedure `braz' is imported, so that the
  21. ;; procedures `foo' and `bar' also exported by that module don't
  22. ;; clash with the definitions of module 0.
  23. ;;
  24. :use-module ((module-2) :select (braz))
  25. ;; Import the bindings from module 2 again, now renaming them by
  26. ;; explicitly mentioning the original and new names.
  27. ;;
  28. :use-module ((module-2) :select ((braz . m-2:braz) (foo . m-2:foo))))
  29. ;;
  30. ;; Now call the various imported procedures.
  31. ;;
  32. (foo)
  33. (bar)
  34. (module-1:foo)
  35. (module-1:bar)
  36. (braz)
  37. (m-2:braz)
  38. (m-2:foo)
  39. ;; Local variables:
  40. ;; mode: scheme
  41. ;; End: