On Monday, October 19, 2015 at 1:00:33 AM UTC, Páll Haraldsson wrote:
>
> On Tuesday, September 1, 2015 at 1:08:38 PM UTC, Jeffrey Sarnoff wrote:
>>
>> import Base:(+),(*),(-)
>>
>> julia> 2+3+4
>> 9
>> julia> (+){T<:Integer}(a::T,b::T,c::T) = ((a+b)+c)+1
>> julia> 2+3+4
>> 10
>>
>> julia> 2-3-4
>> -5
>> julia> (+){T<:Integer}(a::T,b::T,c::T) = ((a-b)-c)-1
>> julia> 2-3-4
>> -5
>>
>> Are (+),(*) the only ops that can be n-ary specialized?
>>
>
> No, it seems not.
>I misread your question for "are (+),(*) the only ops n-ary specialized functions?". I didn't work through, why your "((a-b)-c)-1" didn't work as expected (but I wander why you are doing this.., just a test, like for me, seeing what is possible in Julia..?). I'm sure it has something to do with this: julia> edit(-, (Float64, Float64, Float64)) > ERROR: no method found for the specified argument types > in which at ./reflection.jl:293 > in edit at interactiveutil.jl:58 > If this had been defined analogous to for + I guess it would have worked for you. I'm sure the n-ary minus is just not needed for Julia (I'm sure what I found is just for performance optimization), possibly even dangerous (- is for floating point..). -- Palli.
