Parametrically-constrained arguments not working?

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

They seem to be defining two separate functions for this. We should probably fix that.

@ChrisRackauckas are you suggesting something like the following for this to work properly:

module SharedArrays

import ParallelMeta.localindices

function localindices()
....

Yeah. I’d just slap it in ArrayInterface.jl if it wasn’t a standard library, but being a standard library makes it a bit more difficult. It might require a function localindices end inside of Base…

3 Likes