Discussion: do we always need two import statements?
See original GitHub issueSo this is just something I thought about when reading the new Ceylon tour page about modules and came to the part about the Gotcha of Ceylon always needing two import statements.
Reading that and remembering that quite a number of times when adding a new import to a module I go like “grrr, why am I basically copying this line twice?” I decided to ask the question:
“Really, why exactly do we always have to have two import statements?”
I mean in a Java world where there is(was) no modularity perhaps I can understand needing to import in each source file (after all there isn’t a central place to put them anyway). But in Ceylon what does that gain us exactly? Especially in a time where almost everybody uses IDEs which make looking up things very easy it doesn’t seem as necessary to have the imports appear at the top of each source file.
So how about adding the possibility to mention the declaration you want to import for all files in a module right in the module descriptor?
Like this:
module mymodule "1.0.0" {
// Import a Ceylon module
import ceylon.collection "1.3.0" {
HashMap
}
// Import a native module
import java.base "8" {
java.util { JMap = Map, JHashMap = HashMap }
}
}
You would of course still have the current way. But I see it like this: some people like to specify each and every import, others don’t care so much and just use { ... }
. This would just be a power-version of that.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:8 (8 by maintainers)
Top GitHub Comments
The feature might be available for packages also, like:
I vote for both!
The version number is not supposed to be in the
package
statement I guess?