import statement with narrow scope (more narrow than a compilation unit)
See original GitHub issue[@lukaseder] I’m playing around with import statements, and I’m missing a terrific Scala feature: The possibility of using import statements within any scope level. In Scala, this is possible:
package com.example;
// Scope: This compilation unit
import java.io.Reader;
trait Test {
// Scope: This trait
import java.io.Writer;
def x1() : Reader;
def x2() : Writer;
def x3() : Object = {
// Scope: This method
import java.io.PrintWriter;
return new PrintWriter(x2());
}
}
It seems that the import statement is only possible at a “top level”, i.e. for the compilation unit scope. I think it would be nice if a more narrow scope for import statements was possible, too
[Migrated from ceylon/ceylon-spec#614]
Issue Analytics
- State:
- Created 11 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
suppress deprecation warnings over a narrow scope #7934
Sometimes I'm forced to use a deprecated method. I need to filter these case by case, so that the warnings remain useful generally....
Read more >C++20 modules with GCC11 - Sticky Bits
They have the concepts of exporting and importing types and behaviours from other modules. It is very similar to the public/private semantics of ......
Read more >Compiler Warnings by compiler version | Microsoft Learn
It suppresses all warnings for versions greater than the specified number. For example, /Wv:17 reports warnings introduced in or before any ...
Read more >Why is "using namespace std;" considered bad practice?
Using it in source files (*.cpp) at file scope after all includes is not quite as bad, as its effect is limited to...
Read more >Scope (computer science) - Wikipedia
In computer programming, the scope of a name binding is the part of a program where the name binding is valid; that is,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Heh, in the end we changed our mind @lukaseder 😉
I knew it 😃