Re: Nested public imports - bug or feature?

2015-08-19 Thread Walter Bright via Digitalmars-d
On 8/13/2015 6:12 AM, Dicebot wrote: Right now this works: ``D struct Std { public import std.stdio; } void main() { Std.writeln(Nice!); } ``` I want to use it as an import hygiene idiom but not entirely sure if this behavior can be relied upon (or it is just a side effect of imports

Re: Nested public imports - bug or feature?

2015-08-19 Thread Timon Gehr via Digitalmars-d
On 08/20/2015 01:25 AM, Walter Bright wrote: I want to use it as an import hygiene idiom but not entirely sure if this behavior can be relied upon (or it is just a side effect of imports being implemented as aliases currently). It has nothing to do with aliases. Imports work the same way as

Re: Nested public imports - bug or feature?

2015-08-15 Thread Timon Gehr via Digitalmars-d
On 08/15/2015 06:15 PM, Dicebot wrote: On Friday, 14 August 2015 at 20:12:43 UTC, Timon Gehr wrote: On 08/14/2015 08:57 PM, Dicebot wrote: Ok, let's stop for a minute and make sure we are on the same thread here. Because you seem to argue something I have never said or at least intended to

Re: Nested public imports - bug or feature?

2015-08-15 Thread Dicebot via Digitalmars-d
On Friday, 14 August 2015 at 20:12:43 UTC, Timon Gehr wrote: On 08/14/2015 08:57 PM, Dicebot wrote: Ok, let's stop for a minute and make sure we are on the same thread here. Because you seem to argue something I have never said or at least intended to say. ... OK. This is my view: The

Re: Nested public imports - bug or feature?

2015-08-14 Thread Timon Gehr via Digitalmars-d
On 08/14/2015 08:57 PM, Dicebot wrote: Ok, let's stop for a minute and make sure we are on the same thread here. Because you seem to argue something I have never said or at least intended to say. ... OK. This is my view: The sub-thread was started with the claim that the module system is

Re: Nested public imports - bug or feature?

2015-08-14 Thread Dicebot via Digitalmars-d
Ok, let's stop for a minute and make sure we are on the same thread here. Because you seem to argue something I have never said or at least intended to say. So, my basic statements: 1. I don't like default D import semantics but I am not proposing to change it 2. I like Rust default import

Re: Nested public imports - bug or feature?

2015-08-14 Thread Dejan Lekic via Digitalmars-d
On Thursday, 13 August 2015 at 16:22:04 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 16:19:29 UTC, Jonathan M Davis wrote: You can get that behavior with static imports in D, but having to use the whole import path while referencing symbols gets ugly fast. Check example again, you are

Re: Nested public imports - bug or feature?

2015-08-14 Thread Timon Gehr via Digitalmars-d
On 08/14/2015 05:55 PM, Dejan Lekic wrote: On Thursday, 13 August 2015 at 16:22:04 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 16:19:29 UTC, Jonathan M Davis wrote: You can get that behavior with static imports in D, but having to use the whole import path while referencing symbols gets

Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
Right now this works: ``D struct Std { public import std.stdio; } void main() { Std.writeln(Nice!); } ``` I want to use it as an import hygiene idiom but not entirely sure if this behavior can be relied upon (or it is just a side effect of imports being implemented as aliases currently).

Re: Nested public imports - bug or feature?

2015-08-13 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 13 August 2015 at 13:12:44 UTC, Dicebot wrote: Right now this works: ``D struct Std { public import std.stdio; } void main() { Std.writeln(Nice!); } ``` I want to use it as an import hygiene idiom but not entirely sure if this behavior can be relied upon (or it is just a

Re: Nested public imports - bug or feature?

2015-08-13 Thread rsw0x via Digitalmars-d
On Thursday, 13 August 2015 at 13:12:44 UTC, Dicebot wrote: Right now this works: ``D struct Std { public import std.stdio; } void main() { Std.writeln(Nice!); } ``` I want to use it as an import hygiene idiom but not entirely sure if this behavior can be relied upon (or it is just a

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 03:42 PM, Jonathan M Davis wrote: On Thursday, 13 August 2015 at 13:12:44 UTC, Dicebot wrote: Right now this works: ``D struct Std { public import std.stdio; } void main() { Std.writeln(Nice!); } ``` I want to use it as an import hygiene idiom but not entirely sure if this

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dmitry Olshansky via Digitalmars-d
On 13-Aug-2015 16:56, Timon Gehr wrote: [snip] It has nothing to do with the import being public. This works: --- struct Std{ import std.stdio; } void main(){ Std.writeln(Nice!); } --- (It also works if main and Std are defined in different modules.) but I also don't see how this

Re: Nested public imports - bug or feature?

2015-08-13 Thread Kagamin via Digitalmars-d
As long as imports are not hygienic, this trick is useful. I didn't find it useful in a language with hygienic imports (C#).

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 16:37:00 UTC, Jonathan M Davis wrote: Well, that's better than requiring the full import path, but requiring _any_ module name is just plain annoying IMHO. If I were okay with that I wouldn't be doing stuff like using namespace std; in all of my .cpp files -

Re: Nested public imports - bug or feature?

2015-08-13 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 13 August 2015 at 16:40:31 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 16:37:00 UTC, Jonathan M Davis wrote: Well, that's better than requiring the full import path, but requiring _any_ module name is just plain annoying IMHO. If I were okay with that I wouldn't be doing

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 17:06:18 UTC, Jonathan M Davis wrote: Matter of scale. At some point of application size maintenance cost become much higher than development costs - and problems of name clashes become more important than any extra typing annoyance. Well, if name clashes

Re: Nested public imports - bug or feature?

2015-08-13 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 13 August 2015 at 17:32:33 UTC, Dmitry Olshansky wrote: On 13-Aug-2015 20:17, Jonathan M Davis wrote: On Thursday, 13 August 2015 at 17:09:11 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 17:06:18 UTC, Jonathan M Davis wrote: Matter of scale. At some point of application size

Re: Nested public imports - bug or feature?

2015-08-13 Thread Meta via Digitalmars-d
On Thursday, 13 August 2015 at 17:51:06 UTC, Jonathan M Davis wrote: But the private symbols affecting the public API is just plain embarrassing and definitely makes the problem _far_ worse. - Jonathan M Davis It's worse than embarassing. Every symbol added, public or private, must be

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 06:22 PM, Dicebot wrote: On Thursday, 13 August 2015 at 16:19:29 UTC, Jonathan M Davis wrote: You can get that behavior with static imports in D, but having to use the whole import path while referencing symbols gets ugly fast. Check example again, you are only required to use

Re: Nested public imports - bug or feature?

2015-08-13 Thread jmh530 via Digitalmars-d
On Thursday, 13 August 2015 at 16:40:31 UTC, Dicebot wrote: Matter of scale. At some point of application size maintenance cost become much higher than development costs - and problems of name clashes become more important than any extra typing annoyance. In my C++ projects such using

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dmitry Olshansky via Digitalmars-d
On 13-Aug-2015 20:17, Jonathan M Davis wrote: On Thursday, 13 August 2015 at 17:09:11 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 17:06:18 UTC, Jonathan M Davis wrote: Matter of scale. At some point of application size maintenance cost become much higher than development costs - and

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 16:24:56 UTC, Timon Gehr wrote: static import greetings=phrases.english.greetings; ? http://forum.dlang.org/post/szaaakmavraxatkrf...@forum.dlang.org How is this relevant? Does Rust support it? Relevant as explanation why I don't consider aliased imports a

Re: Nested public imports - bug or feature?

2015-08-13 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 13 August 2015 at 16:22:04 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 16:19:29 UTC, Jonathan M Davis wrote: You can get that behavior with static imports in D, but having to use the whole import path while referencing symbols gets ugly fast. Check example again, you are

Re: Nested public imports - bug or feature?

2015-08-13 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 13 August 2015 at 17:09:11 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 17:06:18 UTC, Jonathan M Davis wrote: Matter of scale. At some point of application size maintenance cost become much higher than development costs - and problems of name clashes become more important

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 06:36 PM, Dicebot wrote: On Thursday, 13 August 2015 at 16:24:56 UTC, Timon Gehr wrote: static import greetings=phrases.english.greetings; ? http://forum.dlang.org/post/szaaakmavraxatkrf...@forum.dlang.org How is this relevant? Does Rust support it? Relevant as explanation

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 15:53:16 UTC, anonymous wrote: On Thursday, 13 August 2015 at 15:29:19 UTC, Dicebot wrote: struct Something { public import a; } void main() { Something.foo(); } What's wrong with `import Something = a;`? Bugs? Works only with a single import: import

Re: Nested public imports - bug or feature?

2015-08-13 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 13 August 2015 at 15:49:10 UTC, Dicebot wrote: On Thursday, 13 August 2015 at 15:40:12 UTC, Timon Gehr wrote: You know about static imports, right? Yes, as well as about renamed and selective ones ;) Problem with static imports is that they are all-or-nothing. And in our

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 15:59:46 UTC, Timon Gehr wrote: On 08/13/2015 05:49 PM, Dicebot wrote: On Thursday, 13 August 2015 at 15:40:12 UTC, Timon Gehr wrote: You know about static imports, right? Yes, as well as about renamed and selective ones ;) Problem with static imports is that

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 06:19 PM, Dicebot wrote: On Thursday, 13 August 2015 at 15:59:46 UTC, Timon Gehr wrote: On 08/13/2015 05:49 PM, Dicebot wrote: On Thursday, 13 August 2015 at 15:40:12 UTC, Timon Gehr wrote: You know about static imports, right? Yes, as well as about renamed and selective ones

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 16:19:29 UTC, Jonathan M Davis wrote: You can get that behavior with static imports in D, but having to use the whole import path while referencing symbols gets ugly fast. Check example again, you are only required to use the plain module name, not fully

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 13:44:50 UTC, rsw0x wrote: And we're back to namespaces : ) Not really. This is namespace: - module a; struct Something { static void foo() {} } module b; import a; void main() { Something.foo(); } - This is import hygiene: - module a; void

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 05:29 PM, Dicebot wrote: On Thursday, 13 August 2015 at 13:44:50 UTC, rsw0x wrote: And we're back to namespaces : ) Not really. This is namespace: - module a; struct Something { static void foo() {} } module b; import a; void main() { Something.foo(); } - This

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 15:40:12 UTC, Timon Gehr wrote: You know about static imports, right? Yes, as well as about renamed and selective ones ;) Problem with static imports is that they are all-or-nothing. And in our projects it is common to have module names with 5 nested packages

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 05:35 PM, Dicebot wrote: On Thursday, 13 August 2015 at 13:42:42 UTC, Jonathan M Davis wrote: I confess that I don't particularly like that this is legal (and I think that public imports tend to get a bit hinky because of the fact that they create aliases), and I'm not quite sure

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 05:34 PM, Dicebot wrote: In any case, I guess we agree that this idiom should work for public imports, but not for non-public ones (so the current behaviour with non-public imports is accepts-invalid, but Dicebot's code should be fine)? I am very curious to learn official

Re: Nested public imports - bug or feature?

2015-08-13 Thread Timon Gehr via Digitalmars-d
On 08/13/2015 05:49 PM, Dicebot wrote: On Thursday, 13 August 2015 at 15:40:12 UTC, Timon Gehr wrote: You know about static imports, right? Yes, as well as about renamed and selective ones ;) Problem with static imports is that they are all-or-nothing. (Which is an arbitrary restriction

Re: Nested public imports - bug or feature?

2015-08-13 Thread Meta via Digitalmars-d
On Thursday, 13 August 2015 at 15:53:16 UTC, anonymous wrote: On Thursday, 13 August 2015 at 15:29:19 UTC, Dicebot wrote: struct Something { public import a; } void main() { Something.foo(); } What's wrong with `import Something = a;`? Bugs? Even better: feature.

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 13:56:24 UTC, Timon Gehr wrote: It has nothing to do with the import being public. This works: --- struct Std{ import std.stdio; } void main(){ Std.writeln(Nice!); } --- (It also works if main and Std are defined in different modules.) Ah, I thought

Re: Nested public imports - bug or feature?

2015-08-13 Thread Dicebot via Digitalmars-d
On Thursday, 13 August 2015 at 13:42:42 UTC, Jonathan M Davis wrote: I confess that I don't particularly like that this is legal (and I think that public imports tend to get a bit hinky because of the fact that they create aliases), and I'm not quite sure how you could use it form import

Re: Nested public imports - bug or feature?

2015-08-13 Thread anonymous via Digitalmars-d
On Thursday, 13 August 2015 at 15:29:19 UTC, Dicebot wrote: struct Something { public import a; } void main() { Something.foo(); } What's wrong with `import Something = a;`? Bugs?