Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Parametrically-constrained arguments not working?

$
0
0

The module testModule (below) defines method iterlocal that calls localindices.

testModule uses DistributedArrays and SharedArrays, which impose mutually-exclusive parametric constraints on localindices so there is no ambiguity when that method is called from iterlocal (without qualification), yet the compiler complains.

How is this behavior consistent with multiple-dispatch?
What is the preferred way to handle this?

module testModule
using DistributedArrays,SharedArrays
export iterlocal
function iterlocal(arr)
    for i in localindices(arr)
        println(arr[i])
    end
end 
end

using DistributedArrays,SharedArrays
a = distribute(fill(rand(2,10),3)) # this is a DArray, it only matches the signature of  DistributedArrays.iterlocal 
test.iterlocal(a)

julia> testMethod.iterlocal(a)
WARNING: both SharedArrays and DistributedArrays export "localindices"; uses of it in module test must be qualified

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795