Julia 中对集合的许多常见操作(例如从 Set 中删除项目)最近被重命名,旧函数已弃用。
例如,
del(IntSet(1,2,3), 1)
现在弹出警告
WARNING: del is deprecated, use delete! instead.
一些重命名的函数:
@deprecate push push!
@deprecate pop pop!
@deprecate grow grow!
@deprecate enqueue unshift!
@deprecate unshift unshift!
@deprecate shift shift!
@deprecate insert insert!
@deprecate del delete!
@deprecate del_all empty!
为什么这些被重命名?正在附加一个!改变集合状态的函数现在是一种约定吗?
最佳答案
您可以阅读 julia-dev
线程 here .基本上,它只是为了尊重 arrays 中描述的规则而改变。文档:
The last function, fill!, is different in that it modifies an existing array instead of constructing a new one. As a convention, functions with this property have names ending with an exclamation point. These functions are sometimes called "mutating" functions, or "in-place" functions.
FWIW 我认为这是个好主意,至少对于
Base
.
关于julia - 为什么在 Julia 中重命名了这些对集合的常见操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14371548/