Bind statement
The bind statement is the counterpart to the mixin statement. It can be used to explicitly declare identifiers that should be bound early (i.e. the identifiers should be looked up in the scope of the template/generic definition):
# Module A
var
lastId = 0
template genId*: untyped =
bind lastId
inc(lastId)
lastId
# Module B
import A
echo genId()
But a bind is rarely useful because symbol binding from the definition scope is the default.
bind statements only make sense in templates and generics.
当前内容版权归 nim-lang.org 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 nim-lang.org .