参数类型的内部构造函数 [英] Inner constructor of parametric type
本文介绍了参数类型的内部构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对参数类型的内部构造函数中的类型注释有些困惑.
I am a bit confused about the type annotations in inner constructor of parametric type.
在JIT推理效率和运行时效率方面,以下4种方法是否有区别?
Are there any difference in the following 4 approaches, in terms of JIT inference efficiency, and runtime efficiency?
immutable MyType{T}
x::T
MyType{T}(x::T) = new{T}(x + x)
end
immutable MyType{T}
x::T
MyType(x::T) = new{T}(x + x)
end
immutable MyType{T}
x::T
MyType(x::T) = new(x + x)
end
immutable MyType{T}
x::T
MyType{T}(x::T) = new(x + x)
end
它们都为x = MyType{Int}(1)
推荐答案
查看全文