zw963
June 18, 2022, 4:51pm
1
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.
zw963
June 18, 2022, 5:06pm
3
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.
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.
zw963
June 18, 2022, 7:29pm
5
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.
opened 06:13AM - 28 Mar 18 UTC
area-language
type-enhancement
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?