63 |
|
|
64 |
** Checking for duplicate bindings in module system |
** Checking for duplicate bindings in module system |
65 |
|
|
66 |
The module system now checks for duplicate imported bindings. |
The module system now can check for name conflicts among imported |
67 |
|
bindings. |
68 |
|
|
69 |
The behavior can be controlled by specifying one or more duplicates |
The behavior can be controlled by specifying one or more duplicates |
70 |
handlers. For example, to get back the old behavior (which was to use |
handlers. For example, to make Guile return an error for every name |
71 |
the last imported binding of a certain name), write: |
collision, write: |
72 |
|
|
73 |
(define-module (foo) |
(define-module (foo) |
74 |
:use-module (bar) |
:use-module (bar) |
75 |
:use-module (baz) |
:use-module (baz) |
76 |
:duplicates last) |
:duplicates check) |
77 |
|
|
78 |
If you want the old behavior without changing your module headers, put |
The new default behavior of the module system when a name collision |
79 |
the line: |
has been detected is to |
80 |
|
|
81 |
|
1. Give priority to bindings marked as a replacement. |
82 |
|
2. Issue a warning. |
83 |
|
3. Give priority to the last encountered binding (this corresponds to |
84 |
|
the old behavior). |
85 |
|
|
86 |
|
If you want the old behavior back without replacements or warnings you |
87 |
|
can add the line: |
88 |
|
|
89 |
(default-duplicate-binding-handler 'last) |
(default-duplicate-binding-handler 'last) |
90 |
|
|
91 |
in your .guile init file. |
to your .guile init file. |
92 |
|
|
93 |
The syntax for the :duplicates option is: |
The syntax for the :duplicates option is: |
94 |
|
|
104 |
warn issue a warning for bindings with a common name |
warn issue a warning for bindings with a common name |
105 |
replace replace bindings which have an imported replacement |
replace replace bindings which have an imported replacement |
106 |
warn-override-core issue a warning for imports which override core bindings |
warn-override-core issue a warning for imports which override core bindings |
107 |
|
and accept the override |
108 |
first select the first encountered binding (override) |
first select the first encountered binding (override) |
109 |
last select the last encountered binding (override) |
last select the last encountered binding (override) |
110 |
|
|
116 |
|
|
117 |
The default duplicates handler is: |
The default duplicates handler is: |
118 |
|
|
119 |
(replace warn-override-core check) |
(replace warn last) |
120 |
|
|
121 |
|
A recommended handler (which is likely to correspond to future Guile |
122 |
|
behavior) can be installed with: |
123 |
|
|
124 |
|
(default-duplicate-binding-handler '(replace warn-override-core check)) |
125 |
|
|
126 |
** New define-module option: :replace |
** New define-module option: :replace |
127 |
|
|