question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 11 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gavinkingcommented, Apr 19, 2017

That’s not to say we couldn’t change our minds and allow it in future, of course.

Heh, in the end we changed our mind @lukaseder 😉

0reactions
lukasedercommented, Apr 19, 2017

I knew it 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found