File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ In your package, write code like the following:
100
100
``` jl
101
101
using FileIO
102
102
103
+ # See important note about scope below
103
104
function load (f:: File{format"PNG"} )
104
105
open (f) do s
105
106
skipmagic (s) # skip over the magic bytes
@@ -126,7 +127,13 @@ function save(f::File{format"PNG"}, data)
126
127
end
127
128
```
128
129
129
- Note that ` load(::File) ` and ` save(::File) ` should close any streams
130
+ Note that these are ` load ` and ` save ` , ** not** ` FileIO.load ` and ` FileIO.save ` .
131
+ Because a given format might have multiple packages that are capable of reading it,
132
+ FileIO will dispatch to these using module-scoping, e.g., ` SomePkg.load(args...) ` .
133
+ Consequently, ** packages should define "private" ` load ` and ` save ` methods, and
134
+ not extend (import) FileIO's** .
135
+
136
+ ` load(::File) ` and ` save(::File) ` should close any streams
130
137
they open. (If you use the ` do ` syntax, this happens for you
131
138
automatically even if the code inside the ` do ` scope throws an error.)
132
139
Conversely, ` load(::Stream) ` and ` save(::Stream) ` should not close the
You can’t perform that action at this time.
0 commit comments