summaryrefslogtreecommitdiff
path: root/examples/modules/main
blob: e4cc71dc73c4df8a4c7f53e07ae49250b21ed2a6 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/local/bin/guile -s
!#
;;; examples/modules/main -- Module system demo.

;;; Commentary:

;;; The main demo program for the modules subdirectory.
;;;
;;; This program shows how all the new fancy module import features
;;; are to be used.

;;; Author: Martin Grabmueller
;;; Date: 2001-05-29

;;; Code:

(define-module (main)
  ;; The module 0 is imported completely.
  ;;
  :use-module (module-0)

  ;; Module 1 is imported completely, too, but the procedure names are
  ;; prefixed with the module name.
  ;;
  :use-module ((module-1) :renamer (symbol-prefix-proc 'module-1:))

  ;; From module 2, only the procedure `braz' is imported, so that the
  ;; procedures `foo' and `bar' also exported by that module don't
  ;; clash with the definitions of module 0.
  ;;
  :use-module ((module-2) :select (braz))
  
  ;; Import the bindings from module 2 again, now renaming them by
  ;; explicitly mentioning the original and new names.
  ;;
  :use-module ((module-2) :select ((braz . m-2:braz) (foo . m-2:foo))))

;;
;; Now call the various imported procedures.
;;

(foo)
(bar)
(module-1:foo)
(module-1:bar)
(braz)
(m-2:braz)
(m-2:foo)

;; Local variables:
;; mode: scheme
;; End: