[Issue 14704] The design, which allows not to write import, import, import ... for selective imports

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jun 17 10:23:03 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14704

--- Comment #7 from dennis.m.ritchie at mail.ru ---
(In reply to Ketmar Dark from comment #6)
> it's so easily doable with simple parser and string mixins, so i can't see
> any sense in changing the compiler.

No one (I repeat, `Nobody`) and will never write like this:

//////////////////////////////////////////////
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));
}
//////////////////////////////////////////////

And I'll bet that if D is such a design, almost all and will always write like
this:

//////////////
import {
    // ...
}
//////////////

I'll never be implemented through the hagfish such things on contests for
sports programming, because it is very time consuming. And, yes, in the end
I'll never import individual modules and thousands of people (since D becomes
popular) in their projects on GitHub will not import the individual functions
of the modules so that they will be too lazy to write `import`,` import`, `
import` ...

Do not believe me? And I would argue that it will be so. I understand that
changes to the compiler requires a lot of work, but still it's worth it to
thousands of people were able to write properly ...

And besides, there is a good principle:
`At the end I want to focus on one philosophical principle, which lies at the
basis of my ideas about the ideal programming language. Typically, during the
discussion in the forums, when you start to talk in a language that is not X
features Y, be sure there is someone who will say: Why, that's if you take the
features A, B and C, and screw them crutches D, E, F, then we will get almost
Y. Yes, it is. But I do not like this approach. One can imagine that such
programmers want some complicated way through the maze. You can go through the
maze, but the way the curve and non-obvious. I also want to be instead of the
labyrinth has a large area, on which from any point to any other one would go
in a straight line. Simply pryamoy.`

And yes. Before you dismiss this issue, think about whether you want to
thousands of programmers on GitHub would not be able to import the individual
functions of the modules in their projects. And all this because someone did
not want to make a small addition to the compiler. I do not want too much to
do, but I do it.
And in this case, I think not only about himself but about globolnoy problem.
After the changes in the language are reflected in thousands of programmers,
thousands!

--


More information about the Digitalmars-d-bugs mailing list