digitalmars.D.learn - How to avoid multiple spelling `import`
- Dennis Ritchie (16/16) Jun 16 2015 Hi,
- Idan Arye (4/20) Jun 16 2015 There is no problem to be solved here. Having to type `import`
- Dennis Ritchie (11/14) Jun 16 2015
- Dennis Ritchie (26/26) Jun 16 2015 Maybe not everyone needs these features. But, unfortunately, I
- Daniel =?UTF-8?B?S296w6Fr?= via Digitalmars-d-learn (25/53) Jun 16 2015 On Tue, 16 Jun 2015 11:45:22 +0000
- Dennis Ritchie (4/28) Jun 16 2015 Thanks. Maybe I'll use this code in your own programs.
- tired_eyes (5/41) Jun 16 2015 I also think this might be useful, and, more important,
- flamencofantasy (2/14) Jun 16 2015 No
- tired_eyes (2/17) Jun 16 2015 Can I have some more serious argumentation than just plain "no"?
- Joy-Killer (5/25) Jun 16 2015 just a word to say that while it's working, anyone who uses this
Hi, I can write this: import std.range : chain, split; But I can not write this: import std.range : chain, split, std.algorithm : map, each; We have several times to write the word `import`: import std.range : chain, split; import std.algorithm : map, each; Does D something to solve this problem? Maybe there is something like: import std.range{chain, split}, std.algorithm{map, each}; import std.range(chain, split), std.algorithm(map, each); import { std.range : chain, split; std.algorithm : map, each; }
Jun 16 2015
On Tuesday, 16 June 2015 at 09:33:22 UTC, Dennis Ritchie wrote:Hi, I can write this: import std.range : chain, split; But I can not write this: import std.range : chain, split, std.algorithm : map, each; We have several times to write the word `import`: import std.range : chain, split; import std.algorithm : map, each; Does D something to solve this problem? Maybe there is something like: import std.range{chain, split}, std.algorithm{map, each}; import std.range(chain, split), std.algorithm(map, each); import { std.range : chain, split; std.algorithm : map, each; }There is no problem to be solved here. Having to type `import` for each imported module is not big enough a burden to justify this additional syntax.
Jun 16 2015
On Tuesday, 16 June 2015 at 11:16:32 UTC, Idan Arye wrote:There is no problem to be solved here. Having to type `import` for each imported module is not big enough a burden to justify this additional syntax.No, I think it is a holdover from C++-times — to write `import` for each new header file. For example, this feature is implemented Go: import ( "os" "bufio" "strings" "fmt" )
Jun 16 2015
Maybe not everyone needs these features. But, unfortunately, I often use a lot of imported modules. And use every time the word `import` very bad. version (none) { import std.math, std.conv, std.stdio, std.ascii, std.range, std.array, std.regex, std.format, std.bigint, std.traits, std.random, std.string, std.numeric, std.variant, std.typecons, std.container, std.algorithm, std.typetuple, std.exception, core.checkedint; } I just want to import individual features of these modules.
Jun 16 2015
On Tue, 16 Jun 2015 11:45:22 +0000 Dennis Ritchie via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Maybe not everyone needs these features. But, unfortunately, I often use a lot of imported modules. And use every time the word `import` very bad. version (none) { import std.math, std.conv, std.stdio, std.ascii, std.range, std.array, std.regex, std.format, std.bigint, std.traits, std.random, std.string, std.numeric, std.variant, std.typecons, std.container, std.algorithm, std.typetuple, std.exception, core.checkedint; } I just want to import individual features of these modules.mixin template include(w...) { mixin _include!(w.length - 1, w); } mixin template _include(long N, i...) { mixin("import " ~ i[N] ~ ";"); mixin _include!(N - 1, i); } mixin template _include(long N : 0, i...) { mixin("import " ~ i[N] ~ ";"); } mixin include!( "std.stdio : writeln, write", "std.conv : to" ); void main() { writeln(to!string(7)); }
Jun 16 2015
On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote:On Tue, 16 Jun 2015 11:45:22 +0000 Dennis Ritchie via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks. Maybe I'll use this code in your own programs. I still believe that this design deserves existence in D: https://issues.dlang.org/show_bug.cgi?id=14704I just want to import individual features of these modules.mixin template include(w...) { mixin _include!(w.length - 1, w); } mixin template _include(long N, i...) { mixin("import " ~ i[N] ~ ";"); mixin _include!(N - 1, i); } mixin template _include(long N : 0, i...) { mixin("import " ~ i[N] ~ ";"); } mixin include!( "std.stdio : writeln, write", "std.conv : to" ); void main() { writeln(to!string(7)); }
Jun 16 2015
On Tuesday, 16 June 2015 at 15:42:02 UTC, Dennis Ritchie wrote:On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote:I also think this might be useful, and, more important, consistent. If we have shorthand syntax for full imports, why there is no option for shorthand partial imports? This is expected behavior.On Tue, 16 Jun 2015 11:45:22 +0000 Dennis Ritchie via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks. Maybe I'll use this code in your own programs. I still believe that this design deserves existence in D: https://issues.dlang.org/show_bug.cgi?id=14704I just want to import individual features of these modules.mixin template include(w...) { mixin _include!(w.length - 1, w); } mixin template _include(long N, i...) { mixin("import " ~ i[N] ~ ";"); mixin _include!(N - 1, i); } mixin template _include(long N : 0, i...) { mixin("import " ~ i[N] ~ ";"); } mixin include!( "std.stdio : writeln, write", "std.conv : to" ); void main() { writeln(to!string(7)); }
Jun 16 2015
On Tuesday, 16 June 2015 at 16:40:39 UTC, tired_eyes wrote:On Tuesday, 16 June 2015 at 15:42:02 UTC, Dennis Ritchie wrote:NoOn Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote:I also think this might be useful, and, more important, consistent. If we have shorthand syntax for full imports, why there is no option for shorthand partial imports? This is expected behavior.[...]Thanks. Maybe I'll use this code in your own programs. I still believe that this design deserves existence in D: https://issues.dlang.org/show_bug.cgi?id=14704
Jun 16 2015
On Wednesday, 17 June 2015 at 01:56:45 UTC, flamencofantasy wrote:On Tuesday, 16 June 2015 at 16:40:39 UTC, tired_eyes wrote:Can I have some more serious argumentation than just plain "no"?On Tuesday, 16 June 2015 at 15:42:02 UTC, Dennis Ritchie wrote:NoOn Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote:I also think this might be useful, and, more important, consistent. If we have shorthand syntax for full imports, why there is no option for shorthand partial imports? This is expected behavior.[...]Thanks. Maybe I'll use this code in your own programs. I still believe that this design deserves existence in D: https://issues.dlang.org/show_bug.cgi?id=14704
Jun 16 2015
On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote:mixin template include(w...) { mixin _include!(w.length - 1, w); } mixin template _include(long N, i...) { mixin("import " ~ i[N] ~ ";"); mixin _include!(N - 1, i); } mixin template _include(long N : 0, i...) { mixin("import " ~ i[N] ~ ";"); } mixin include!( "std.stdio : writeln, write", "std.conv : to" ); void main() { writeln(to!string(7)); }just a word to say that while it's working, anyone who uses this shouldn't expect the tools, i particularly think to DCD, to work anymore with this. e.g jump to definition...show ddoc...completion won't work.
Jun 16 2015