# Parametrically-constrained arguments not working?

**URL:** https://discourse.julialang.org/t/parametrically-constrained-arguments-not-working/52975
**Category:** New to Julia
**Tags:** question, dispatch
**Created:** [January 7, 2021, 5:20am UTC](https://discourse.julialang.org/t/parametrically-constrained-arguments-not-working/52975 "2021-01-07T05:20:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)
#### Post date: [January 7, 2021, 5:20am UTC](https://discourse.julialang.org/t/parametrically-constrained-arguments-not-working/52975/1 "2021-01-07T05:20:24Z")

</div>

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?

```julia
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

```

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [January 7, 2021, 5:39am UTC](https://discourse.julialang.org/t/parametrically-constrained-arguments-not-working/52975/2 "2021-01-07T05:39:24Z")

</div>

> [@mkarikom](#):
>
> `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.

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

---

<div class="post-metadata">

### Author: ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)
#### Post date: [January 7, 2021, 5:55am UTC](https://discourse.julialang.org/t/parametrically-constrained-arguments-not-working/52975/4 "2021-01-07T05:55:31Z")

</div>

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

```julia
module SharedArrays

import ParallelMeta.localindices

function localindices()
....

```

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [January 7, 2021, 5:59am UTC](https://discourse.julialang.org/t/parametrically-constrained-arguments-not-working/52975/5 "2021-01-07T05:59:23Z")

</div>

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…
