# There are two shards which define same name module and same method signature, how to use both shards?

**URL:** <https://forum.crystal-lang.org/t/there-are-two-shards-which-define-same-name-module-and-same-method-signature-how-to-use-both-shards/4698>\
**Category:** Help & Support\
**Created:** [June 18, 2022, 4:51pm UTC](https://forum.crystal-lang.org/t/there-are-two-shards-which-define-same-name-module-and-same-method-signature-how-to-use-both-shards/4698 "2022-06-18T16:51:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [June 18, 2022, 4:51pm UTC](https://forum.crystal-lang.org/t/there-are-two-shards-which-define-same-name-module-and-same-method-signature-how-to-use-both-shards/4698/1 "2022-06-18T16:51:52Z")

</div>

We do a assume:

We hare two shards, both define Base58 module, one of the define #encode, #decode, another one define #encode only

So, how to use both shards in my project? how to differentiate them?

is there a way like go import, add a alias for avoid conflict?

Thank you.

---

<div class="post-metadata">

**Author:** ![bcardiff](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/bcardiff/32/3_2.png) [@bcardiff](https://forum.crystal-lang.org/u/bcardiff)\
**Post date:** [June 18, 2022, 4:58pm UTC](https://forum.crystal-lang.org/t/there-are-two-shards-which-define-same-name-module-and-same-method-signature-how-to-use-both-shards/4698/2 "2022-06-18T16:58:55Z")

</div>

There is no way to include both shards and distinguish them. Namespace are global.

---

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [June 18, 2022, 5:06pm UTC](https://forum.crystal-lang.org/t/there-are-two-shards-which-define-same-name-module-and-same-method-signature-how-to-use-both-shards/4698/3 "2022-06-18T17:06:52Z")

</div>

If two shard use same module name, later defined can open the earlier defined, right?

this is a common issue from ruby, it’s seem like still exists on crystal. 😄

---

<div class="post-metadata">

**Author:** ![bcardiff](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/bcardiff/32/3_2.png) [@bcardiff](https://forum.crystal-lang.org/u/bcardiff)\
**Post date:** [June 18, 2022, 5:57pm UTC](https://forum.crystal-lang.org/t/there-are-two-shards-which-define-same-name-module-and-same-method-signature-how-to-use-both-shards/4698/4 "2022-06-18T17:57:16Z")

</div>

Yes. Modules and classes can be reopened. I think is an consequence of wanting global namespace and allowing monkey-patching.

That means that as a final user you could load shard A, alias method to re-expose it with a different name, then load shard B.

But that if shard A is used as intermediate dependency this will nos dependants of A to keep using A. They will use B.

But as an end user you can do that.

---

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [June 18, 2022, 7:29pm UTC](https://forum.crystal-lang.org/t/there-are-two-shards-which-define-same-name-module-and-same-method-signature-how-to-use-both-shards/4698/5 "2022-06-18T19:29:24Z")

</div>

Yes, in fact, i hope get the same power in dart, because some flutter package do wrong setting hard-code in package, i want to change it, but there is no way to do that, you never ever open and fix the class defined in package.

I don’t know how crystal get this, this make crystal wonderful !

BTW: following is some discuss about monkey patch of dart, since 2018, still not add it.

> <https://github.com/dart-lang/sdk/issues/32700>
>
> What is the possibility that this could end up in the Dart engine. This is one …feature that I find I really miss compared to JavaScript.
> 
> If someone industrious could add this feature; would it be accepted; or is it pretty hard to get new language level features added because of being under a language standard?
