digitalmars.D.learn - Is anything private by default when declared in a module?
- Gary Willoughby (5/5) Dec 02 2013 Is anything private by default when declared in a module?
- Adam D. Ruppe (4/5) Dec 02 2013 I believe imports only. "import foo;" is private, so you write
- Namespace (5/11) Dec 02 2013 But sadly named imports aren't private...
- H. S. Teoh (6/20) Dec 02 2013 WAT?
- Gary Willoughby (2/23) Dec 02 2013 WAT?++
- Namespace (14/35) Dec 02 2013 I mean yes, but I find nothing.
- Namespace (3/43) Dec 02 2013 I have found it
- lomereiter (3/4) Dec 02 2013 OMG now I get it why in 2.064 importing std.regex makes visible
- eles (4/7) Dec 03 2013 Unicorns cannot be white, as they are already pink & invisible.
- Jonathan M Davis (6/25) Dec 02 2013 Yes. It's a longstanding bug with regards to selective imports. They cre...
- Adam D. Ruppe (15/19) Dec 03 2013 Well, that's sometimes useful, it helps get rid of conflict
- H. S. Teoh (13/24) Dec 03 2013 Yeah, that's pretty annoying. Once I wrote a module that exports a
Is anything private by default when declared in a module? I'm declaring functions, classes, structs, enums, aliases, etc.. I'm assuming all these are public by default when declared in a module to allow them to be imported into another. Is there anything private by default when declared in a module?
Dec 02 2013
On Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:Is anything private by default when declared in a module?I believe imports only. "import foo;" is private, so you write "public import foo;" to expose outside. But other than that, I'm pretty sure everything is public unless you say otherwise.
Dec 02 2013
On Monday, 2 December 2013 at 20:46:58 UTC, Adam D. Ruppe wrote:On Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:But sadly named imports aren't private... /// module foo private import std.stdio: writeln; writeln can be used in any module which imports foo. :/Is anything private by default when declared in a module?I believe imports only. "import foo;" is private, so you write "public import foo;" to expose outside. But other than that, I'm pretty sure everything is public unless you say otherwise.
Dec 02 2013
On Mon, Dec 02, 2013 at 09:53:09PM +0100, Namespace wrote:On Monday, 2 December 2013 at 20:46:58 UTC, Adam D. Ruppe wrote:WAT? That's messed up. Is there a bug for that? T -- Why waste time learning, when ignorance is instantaneous? -- Hobbes, from Calvin & HobbesOn Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:But sadly named imports aren't private... /// module foo private import std.stdio: writeln; writeln can be used in any module which imports foo. :/Is anything private by default when declared in a module?I believe imports only. "import foo;" is private, so you write "public import foo;" to expose outside. But other than that, I'm pretty sure everything is public unless you say otherwise.
Dec 02 2013
On Monday, 2 December 2013 at 21:10:44 UTC, H. S. Teoh wrote:On Mon, Dec 02, 2013 at 09:53:09PM +0100, Namespace wrote:WAT?++On Monday, 2 December 2013 at 20:46:58 UTC, Adam D. Ruppe wrote:WAT? That's messed up. Is there a bug for that? TOn Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:But sadly named imports aren't private... /// module foo private import std.stdio: writeln; writeln can be used in any module which imports foo. :/Is anything private by default when declared in a module?I believe imports only. "import foo;" is private, so you write "public import foo;" to expose outside. But other than that, I'm pretty sure everything is public unless you say otherwise.
Dec 02 2013
On Monday, 2 December 2013 at 21:10:44 UTC, H. S. Teoh wrote:On Mon, Dec 02, 2013 at 09:53:09PM +0100, Namespace wrote:I mean yes, but I find nothing. Short example: io.d ---- private import std.stdio : writeln; ---- io_use.d ---- import io; void main() { writeln("Hello"); } ----On Monday, 2 December 2013 at 20:46:58 UTC, Adam D. Ruppe wrote:WAT? That's messed up. Is there a bug for that? TOn Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:But sadly named imports aren't private... /// module foo private import std.stdio: writeln; writeln can be used in any module which imports foo. :/Is anything private by default when declared in a module?I believe imports only. "import foo;" is private, so you write "public import foo;" to expose outside. But other than that, I'm pretty sure everything is public unless you say otherwise.
Dec 02 2013
On Monday, 2 December 2013 at 21:30:08 UTC, Namespace wrote:On Monday, 2 December 2013 at 21:10:44 UTC, H. S. Teoh wrote:I have found it https://github.com/D-Programming-Language/dmd/pull/2256On Mon, Dec 02, 2013 at 09:53:09PM +0100, Namespace wrote:I mean yes, but I find nothing. Short example: io.d ---- private import std.stdio : writeln; ---- io_use.d ---- import io; void main() { writeln("Hello"); } ----On Monday, 2 December 2013 at 20:46:58 UTC, Adam D. Ruppe wrote:WAT? That's messed up. Is there a bug for that? TOn Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:But sadly named imports aren't private... /// module foo private import std.stdio: writeln; writeln can be used in any module which imports foo. :/Is anything private by default when declared in a module?I believe imports only. "import foo;" is private, so you write "public import foo;" to expose outside. But other than that, I'm pretty sure everything is public unless you say otherwise.
Dec 02 2013
On Monday, 2 December 2013 at 20:53:10 UTC, Namespace wrote:But sadly named imports aren't private...OMG now I get it why in 2.064 importing std.regex makes visible std.uni.isWhite all of a sudden.
Dec 02 2013
On Monday, 2 December 2013 at 21:28:48 UTC, lomereiter wrote:On Monday, 2 December 2013 at 20:53:10 UTC, Namespace wrote:OMG now I get it why in 2.064 importing std.regex makes visible std.uni.isWhite all of a sudden.Unicorns cannot be white, as they are already pink & invisible. At least the std ones... http://en.wikipedia.org/wiki/Invisible_Pink_Unicorn
Dec 03 2013
On Monday, December 02, 2013 13:09:06 H. S. Teoh wrote:On Mon, Dec 02, 2013 at 09:53:09PM +0100, Namespace wrote:Yes. It's a longstanding bug with regards to selective imports. They create a conflicting symbol in the importing module's scope. That's why you should never use them at this point. https://d.puremagic.com/issues/show_bug.cgi?id=314 - Jonathan M DavisOn Monday, 2 December 2013 at 20:46:58 UTC, Adam D. Ruppe wrote:WAT? That's messed up. Is there a bug for that?On Monday, 2 December 2013 at 20:43:23 UTC, Gary Willoughby wrote:But sadly named imports aren't private... /// module foo private import std.stdio: writeln; writeln can be used in any module which imports foo. :/Is anything private by default when declared in a module?I believe imports only. "import foo;" is private, so you write "public import foo;" to expose outside. But other than that, I'm pretty sure everything is public unless you say otherwise.
Dec 02 2013
On Tuesday, 3 December 2013 at 07:34:37 UTC, Jonathan M Davis wrote:They create a conflicting symbol in the importing module's scope. That's why you should never use them at this point.Well, that's sometimes useful, it helps get rid of conflict errors quickly, easily, and explicitly. It should just be a private name in the new scope unless the import was public. BTW private names should be outright invisible outside the module. At least private things at module scope. I get really annoyed with "public symbol foo from module bar conflicts with private symbol foo from module baz". Gee, I wonder which one I wanted to use??? But that's a separate issue.https://d.puremagic.com/issues/show_bug.cgi?id=314wait, I thought Kenji fixed that? The comments don't say why it was reopened... did it just break too much Phobos code or was the fix wrong in some other way?
Dec 03 2013
On Tue, Dec 03, 2013 at 04:16:04PM +0100, Adam D. Ruppe wrote: [...]BTW private names should be outright invisible outside the module. At least private things at module scope. I get really annoyed with "public symbol foo from module bar conflicts with private symbol foo from module baz". Gee, I wonder which one I wanted to use???Yeah, that's pretty annoying. Once I wrote a module that exports a symbol that just so happens coincided with a private symbol in std.regex, and the compiler complained all over the place about it. Pretty annoying. Worse yet, the code *worked* when the code that referenced that symbol was in the same module, but when it was moved out during code reorg, it started to fail compiling. I was not very happy with that. (And doesn't that go against what TDPL says, too?)But that's a separate issue.The pull linked to in the bug hasn't been merged yet. T -- Long, long ago, the ancient Chinese invented a device that lets them see through walls. It was called the "window".https://d.puremagic.com/issues/show_bug.cgi?id=314wait, I thought Kenji fixed that? The comments don't say why it was reopened... did it just break too much Phobos code or was the fix wrong in some other way?
Dec 03 2013