@@ -42,11 +42,13 @@ the system will search for it among variables exported by `Lib` and import it if
42
42
This means that all uses of that global within the current module will resolve to the definition
43
43
of that variable in ` Lib ` .
44
44
45
- The statement ` using BigLib: thing1, thing2 ` is a syntactic shortcut for ` using BigLib.thing1, BigLib.thing2 ` .
45
+ The statement ` using BigLib: thing1, thing2 ` brings just the identifiers ` thing1 ` and ` thing2 `
46
+ into scope from module ` BigLib ` . If these names refer to functions, adding methods to them
47
+ will not be allowed (you may only "use" them, not extend them).
46
48
47
- The ` import ` keyword supports all the same syntax as ` using ` , but only operates on a single name
49
+ The ` import ` keyword supports the same syntax as ` using ` , but only operates on a single name
48
50
at a time. It does not add modules to be searched the way ` using ` does. ` import ` also differs
49
- from ` using ` in that functions must be imported using ` import ` to be extended with new methods.
51
+ from ` using ` in that functions imported using ` import ` can be extended with new methods.
50
52
51
53
In ` MyModule ` above we wanted to add a method to the standard ` show ` function, so we had to write
52
54
` import Base.show ` . Functions whose names are only visible via ` using ` cannot be extended.
@@ -79,7 +81,6 @@ functions into the current workspace:
79
81
| Import Command | What is brought into scope | Available for method extension |
80
82
| :------------------------------- | :------------------------------------------------------------------------------- | :------------------------------------------- |
81
83
| ` using MyModule ` | All ` export ` ed names (` x ` and ` y ` ), ` MyModule.x ` , ` MyModule.y ` and ` MyModule.p ` | ` MyModule.x ` , ` MyModule.y ` and ` MyModule.p ` |
82
- | ` using MyModule.x, MyModule.p ` | ` x ` and ` p ` | |
83
84
| ` using MyModule: x, p ` | ` x ` and ` p ` | |
84
85
| ` import MyModule ` | ` MyModule.x ` , ` MyModule.y ` and ` MyModule.p ` | ` MyModule.x ` , ` MyModule.y ` and ` MyModule.p ` |
85
86
| ` import MyModule.x, MyModule.p ` | ` x ` and ` p ` | ` x ` and ` p ` |
0 commit comments