Re: [julia-users] constructor & function have different promotion rules?

2016-04-05 Thread FANG Colin
Thank you On 5 April 2016 at 15:47, Josh Langsfeld wrote: > This is noted in the docs. See a few paragraphs down, "When a type is > applied like a function..." > > http://docs.julialang.org/en/release-0.4/manual/types/#composite-types > > On Tuesday, April 5, 2016 at 10:19:05

Re: [julia-users] constructor & function have different promotion rules?

2016-04-05 Thread Josh Langsfeld
This is noted in the docs. See a few paragraphs down, "When a type is applied like a function..." http://docs.julialang.org/en/release-0.4/manual/types/#composite-types On Tuesday, April 5, 2016 at 10:19:05 AM UTC-4, FANG Colin wrote: > > methods(TT) > > call(::Type{TT}, x::Float64,

Re: [julia-users] constructor & function have different promotion rules?

2016-04-05 Thread Sisyphuss
Yes, I guess. call(TT, 1, 2) call(TT, 'a', 'b') On Tuesday, April 5, 2016 at 4:19:05 PM UTC+2, FANG Colin wrote: > > methods(TT) > > call(::Type{TT}, x::Float64, y::Float64) at In[22]:2 > call(::Type{TT}, x, y) at In[22]:2 > call{T}(::Type{T}, arg) at essentials.jl:56

Re: [julia-users] constructor & function have different promotion rules?

2016-04-05 Thread FANG Colin
methods(TT) call(::Type{TT}, x::Float64, y::Float64) at In[22]:2 call(::Type{TT}, x, y) at In[22]:2 call{T}(::Type{T}, arg) at essentials.jl:56 call{T}(::Type{T}, args...) at essentials.jl:57 So I guess the rule is applied in call(::Type{TT}, x, y) What does it do? Does it try to

Re: [julia-users] constructor & function have different promotion rules?

2016-04-05 Thread Yichao Yu
On Tue, Apr 5, 2016 at 10:09 AM, FANG Colin wrote: > Sorry if this has been discussed somewhere as I am unable to find the > relative post. > > immutable TT > x::Float64 > y::Float64 > end > > function tt(x::Float64, y::Float64) > x + y > > end > tt(1,2) # doesn't

[julia-users] constructor & function have different promotion rules?

2016-04-05 Thread FANG Colin
Sorry if this has been discussed somewhere as I am unable to find the relative post. immutable TT x::Float64 y::Float64 end function tt(x::Float64, y::Float64) x + y end tt(1,2) # doesn't work TT(1,2) # works What rule applies here for TT(1,2)?