Export statement
An export statement can be used for symbol forwarding so that client modules don’t need to import a module’s dependencies:
# module B
type MyObject* = object
# module A
import B
export B.MyObject
proc `$`*(x: MyObject): string = "my object"
# module C
import A
# B.MyObject has been imported implicitly here:
var x: MyObject
echo $x
When the exported symbol is another module, all of its definitions will be forwarded. One can use an except list to exclude some of the symbols.
Notice that when exporting, one needs to specify only the module name:
import foo/bar/baz
export baz
当前内容版权归 nim-lang.org 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 nim-lang.org .