-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow resources with the same name to be imported from different modules and used in statements/expressions #431
Comments
An alternative to this could be to support aliases for resources. Something like this:
This would also be beneficial for module imports too, I think. Implementation wise, an extra normalisation pass would be required, transforming resource aliases into their fully qualified names, and then replacing any resource-variable reference with that alias as a reference to said resource. |
That's a great idea! I'll change the title of this issue. |
I'm thinking also, we could do this at the proc level:
It has the benefit of being easier to parse (as we don't have a new top-level item to parse, and can also be extended to use blocks:
but it has the downside of being repeated everywhere the resource is used if there's a conflict in that proc/use block. Now that I'm thinking about it, though, I like my original syntax better. It has the benefit of being applicable to more than just resources, potentially giving aliases for procs and types 👀 |
One of the principles of resources is to name things consistently. Of course, the case under discussion is where we can't do that due to conflict, but I think it's still desirable in this case to be as consistent as we can. In this case, that's file-level consistency, which your first suggestion provides. I'm not sure if it's really warranted, but we could generalise this idea to cover procs and functions and even types by providing a syntax to rename things as they are imported. Maybe generalise the existing
to use the name |
I like the idea of having aliases for anything that can be exported. Using
I assume that this aliasing would have to be restricted to aliasing all items that have the same name (synonymous procs with differing arities/modes), unless we introduce some syntax for that, a la
|
This will permit a much more satisfactory fix for #414. Until then, procs that use the multiple resources with the same resource name (and different modules) can't be supported, and that includes any module that imports multiple modules that each define initialised resources with the same name and has top-level code.
The text was updated successfully, but these errors were encountered: