Re: Named multi-imports

2017-08-18 Thread Olivier FAURE via Digitalmars-d
On Friday, 18 August 2017 at 09:18:42 UTC, Timon Gehr wrote: Any downsides? ... - It introduces a new type that would not really be necessary. This is avoidable, at the cost of a little more verbosity: D newbie here: is there a non-negligible cost to creating a stateless struct type?

Re: Named multi-imports

2017-08-18 Thread jmh530 via Digitalmars-d
On Friday, 18 August 2017 at 09:18:42 UTC, Timon Gehr wrote: --- module util; // ... template Imports(T...){ import std.string,std.algorithm; mixin([T].map!(x=>"public import "~x~";").join); // or, starting from DMD 2.076, you could use static foreach instead: // static

Re: Named multi-imports

2017-08-18 Thread Timon Gehr via Digitalmars-d
On 18.08.2017 03:11, Johnson Jones wrote: private struct oo{ import std.stdio: writeln, write; import std.algorithm: filter, map; // … } void main(){ oo.write("result: "); oo.writeln(oo.map!(x=>x/2)(oo.filter!(x=>x%2==0)([1,2,3,4,5,6,10]))); } Wow, that might solve the

Re: Named multi-imports

2017-08-18 Thread Timon Gehr via Digitalmars-d
On 18.08.2017 01:25, jmh530 wrote: On Thursday, 17 August 2017 at 21:49:38 UTC, Timon Gehr wrote: private struct oo{ import std.stdio: writeln, write; import std.algorithm: filter, map; // … } void main(){ oo.write("result: ");

Re: Named multi-imports

2017-08-17 Thread Johnson Jones via Digitalmars-d
On Thursday, 17 August 2017 at 21:49:38 UTC, Timon Gehr wrote: On 17.08.2017 23:03, aberba wrote: On Wednesday, 16 August 2017 at 13:57:17 UTC, jmh530 wrote: On Wednesday, 16 August 2017 at 09:54:41 UTC, aberba wrote: This looks really clean for code modularity. import io = std.stdio :

Re: Named multi-imports

2017-08-17 Thread jmh530 via Digitalmars-d
On Thursday, 17 August 2017 at 21:49:38 UTC, Timon Gehr wrote: private struct oo{ import std.stdio: writeln, write; import std.algorithm: filter, map; // … } void main(){ oo.write("result: "); oo.writeln(oo.map!(x=>x/2)(oo.filter!(x=>x%2==0)([1,2,3,4,5,6,10]))); } Would

Re: Named multi-imports

2017-08-17 Thread Timon Gehr via Digitalmars-d
On 17.08.2017 23:03, aberba wrote: On Wednesday, 16 August 2017 at 13:57:17 UTC, jmh530 wrote: On Wednesday, 16 August 2017 at 09:54:41 UTC, aberba wrote: This looks really clean for code modularity. import io = std.stdio : {writeln, write}, ... What does this add? A line like below would

Re: Named multi-imports

2017-08-17 Thread Johnson Jones via Digitalmars-d
On Thursday, 17 August 2017 at 21:03:33 UTC, aberba wrote: On Wednesday, 16 August 2017 at 13:57:17 UTC, jmh530 wrote: On Wednesday, 16 August 2017 at 09:54:41 UTC, aberba wrote: This looks really clean for code modularity. import io = std.stdio : {writeln, write}, ... What does this add?

Re: Named multi-imports

2017-08-17 Thread aberba via Digitalmars-d
On Wednesday, 16 August 2017 at 13:57:17 UTC, jmh530 wrote: On Wednesday, 16 August 2017 at 09:54:41 UTC, aberba wrote: This looks really clean for code modularity. import io = std.stdio : {writeln, write}, ... What does this add? A line like below would be confusing. import io = std.stdio

Re: New Features [was Named multi-imports]

2017-08-17 Thread Jesse Phillips via Digitalmars-d
This was hard to keep reading, but ultimately enjoyable, because your arguments stem from interpretations and opinions of my point rather than the points I was making. It is interesting that you feel I've claimed your point is baseless when I made no attempt to say such. Would help if I

Re: Named multi-imports

2017-08-17 Thread jmh530 via Digitalmars-d
On Thursday, 17 August 2017 at 11:40:11 UTC, rjframe wrote: It doesn't quite work; it provides access to all names in the module, and write/writeln is introduced into the global namespace; e.g., it's interpreted as `import io = std.stdio; import std.stdio : write, writeln;`

Re: Named multi-imports

2017-08-17 Thread rjframe via Digitalmars-d
On Wed, 16 Aug 2017 12:04:13 +, jmh530 wrote: > > Well I knew that renamed imports were allowed, but I didn't realize you > could do re-named selective imports (the " : writeln, > write" part of it). I just double-checked and it worked. I don't recall > it working in the past. > > I see that

Re: New Features [was Named multi-imports]

2017-08-16 Thread Johnson Jones via Digitalmars-d
On Wednesday, 16 August 2017 at 19:05:54 UTC, Jesse Phillips wrote: On Tuesday, 15 August 2017 at 20:33:18 UTC, Johnson wrote: On Tuesday, 15 August 2017 at 03:37:39 UTC, rikki cattermole wrote: But then that only helps with one specific instance. D is full of language features, I do not see

Re: Named multi-imports

2017-08-16 Thread jmh530 via Digitalmars-d
On Wednesday, 16 August 2017 at 18:38:23 UTC, Johnson Jones wrote: Not really, I'm not doing selective imports. [snip] I'll preface this by saying that I think Jesse Phillips' point is a good one. The fact that you can already do it with the language (as you note about having a separate

New Features [was Named multi-imports]

2017-08-16 Thread Jesse Phillips via Digitalmars-d
On Tuesday, 15 August 2017 at 20:33:18 UTC, Johnson wrote: On Tuesday, 15 August 2017 at 03:37:39 UTC, rikki cattermole wrote: But then that only helps with one specific instance. D is full of language features, I do not see why everyone is so against them. Without them, D would be empty,

Re: Named multi-imports

2017-08-16 Thread Johnson Jones via Digitalmars-d
On Wednesday, 16 August 2017 at 17:14:49 UTC, jmh530 wrote: On Wednesday, 16 August 2017 at 14:42:51 UTC, Mike Wey wrote: Wouldn't that just move the problem? You then get an package that imports gtk.Window and a other package that imports gdk.Window, and if you want to use both you still

Re: Named multi-imports

2017-08-16 Thread jmh530 via Digitalmars-d
On Wednesday, 16 August 2017 at 14:42:51 UTC, Mike Wey wrote: Wouldn't that just move the problem? You then get an package that imports gtk.Window and a other package that imports gdk.Window, and if you want to use both you still need to add a renamed import or a static import in your own

Re: Named multi-imports

2017-08-16 Thread Mike Wey via Digitalmars-d
On 16-08-17 09:58, Gary Willoughby wrote: On Tuesday, 15 August 2017 at 03:37:39 UTC, rikki cattermole wrote: On 15/08/2017 2:59 AM, Johnson wrote: Not only that, but it requires adding more files to the command line. I currently have 3 import files to separate the gtk from gdk that and the

Re: Named multi-imports

2017-08-16 Thread jmh530 via Digitalmars-d
On Wednesday, 16 August 2017 at 09:54:41 UTC, aberba wrote: This looks really clean for code modularity. import io = std.stdio : {writeln, write}, ... What does this add? A line like below would be confusing. import io = std.stdio : {writeln, write}, writefln; The following code compiles

Re: Named multi-imports

2017-08-16 Thread Johnson via Digitalmars-d
On Wednesday, 16 August 2017 at 09:54:41 UTC, aberba wrote: On Tuesday, 15 August 2017 at 21:12:24 UTC, jmh530 wrote: On Tuesday, 15 August 2017 at 20:33:18 UTC, Johnson wrote: Or instead of a new language feature, the gtk-d guys could have package files ;) But then that only helps with

Re: Named multi-imports

2017-08-16 Thread jmh530 via Digitalmars-d
On Wednesday, 16 August 2017 at 10:12:01 UTC, Joel Nilsson wrote: On Tuesday, 15 August 2017 at 21:12:24 UTC, jmh530 wrote: In the past, I've thought it would be convenient to have something like import io = std.stdio : writeln, write; and allow someone to write io.write("foo");

Re: Named multi-imports

2017-08-16 Thread Joel Nilsson via Digitalmars-d
On Tuesday, 15 August 2017 at 21:12:24 UTC, jmh530 wrote: In the past, I've thought it would be convenient to have something like import io = std.stdio : writeln, write; and allow someone to write io.write("foo"); io.writeln("bar"); This is already in the language:

Re: Named multi-imports

2017-08-16 Thread aberba via Digitalmars-d
On Tuesday, 15 August 2017 at 21:12:24 UTC, jmh530 wrote: On Tuesday, 15 August 2017 at 20:33:18 UTC, Johnson wrote: Or instead of a new language feature, the gtk-d guys could have package files ;) But then that only helps with one specific instance. D is full of language features, I do

Re: Named multi-imports

2017-08-16 Thread Gary Willoughby via Digitalmars-d
On Tuesday, 15 August 2017 at 03:37:39 UTC, rikki cattermole wrote: On 15/08/2017 2:59 AM, Johnson wrote: Not only that, but it requires adding more files to the command line. I currently have 3 import files to separate the gtk from gdk that and the only reason they exist is to combine them

Re: Named multi-imports

2017-08-15 Thread jmh530 via Digitalmars-d
On Tuesday, 15 August 2017 at 20:33:18 UTC, Johnson wrote: Or instead of a new language feature, the gtk-d guys could have package files ;) But then that only helps with one specific instance. D is full of language features, I do not see why everyone is so against them. Without them, D

Re: Named multi-imports

2017-08-15 Thread Johnson via Digitalmars-d
On Tuesday, 15 August 2017 at 03:37:39 UTC, rikki cattermole wrote: On 15/08/2017 2:59 AM, Johnson wrote: Not only that, but it requires adding more files to the command line. I currently have 3 import files to separate the gtk from gdk that and the only reason they exist is to combine them

Re: Named multi-imports

2017-08-14 Thread rikki cattermole via Digitalmars-d
On 15/08/2017 2:59 AM, Johnson wrote: Not only that, but it requires adding more files to the command line. I currently have 3 import files to separate the gtk from gdk that and the only reason they exist is to combine them in to one named import ;/ Doesn't seem like much but that's 3 extra

Re: Named multi-imports

2017-08-14 Thread Johnson via Digitalmars-d
Not only that, but it requires adding more files to the command line. I currently have 3 import files to separate the gtk from gdk that and the only reason they exist is to combine them in to one named import ;/ Doesn't seem like much but that's 3 extra files that don't really need to

Named multi-imports

2017-08-14 Thread Johnson via Digitalmars-d
Why can't we name multiple imports? import x = a, b, c; only a is part of x, b and c are not named! this can cause some major problems(or the lack of a correctly solution). For example, gdk and gtk both have window. Both imports are needed and both define many public imports that create a