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

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.

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

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. :smile:

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.

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.