3 ms·
I don't see how that would allow you to do both import list "container/list" {Value: int} import list "container/list" {Value: string} in a single source
by Someone 9y ago
I don't see how that would allow you to do both
import list "container/list" {Value: int}
import list "container/list" {Value: string}
in a single source file. At the least, you would need the ability to give the type(s) that those import statements import distinctive names.
Even that would, IMO, not be enough, as this seems (from what I infer the semantics to be) to make it impossible for writers of such a generic library to build on another generic library.
That can be fixed by allowing such a programmer to write:
package foo {MyValue: interface{}}
...
import list "container/list" {Value: MyValue}
but that, IMO, would be way too cumbersome. That package declaration would have to mention all types in all generic packages that get imported.
- GauntletWizard 9y agoGo already allows you to rename imports. It's already used in the example provided, actually; the first token is the aliased name of the package. I.e. import intlist "container/list" {Value: int} import stringlist "container/list" {Value: string}
- Someone 9y agoThanks. I didn't realize that the second token was a user-specified name. So, this basically would boil down to something like C++ templates, with he extra requirement that templates must be instantiated explicitly.