July 30, 2013
On Tuesday, 30 July 2013 at 14:31:00 UTC, Kenji Hara wrote:
> 2013/7/30 Dicebot <public@dicebot.lv>
>
>> On Tuesday, 30 July 2013 at 12:29:00 UTC, Daniel Murphy wrote:
>>
>>> Please file a bug report: http://d.puremagic.com/issues/
>>>
>>
>> I don't think it is a bug, enhancement request for error message at most.
>>
>
> Currently selective import *implicitly* creates alias declaration for each
> picked up names, and two equivalent selective import will make two alias
> declarations implicitly, then they conflict each other.
>
> import std.conv : to;
> import std.conv : to;
>
> is mostly same as:
>
> import std.conv;
> alias to = std.conv.to;
> alias to = std.conv.to;  // conflict with the first alias
>
> I think it's a not good compiler implementation detail and unnecessary
> intrusive behavior.
> Now I'm proposing to fix import mechanism in here.
> https://github.com/D-Programming-Language/dmd/pull/2256
>
> Kenji Hara

I figured some aliasing was going on underneath(hence the error).

Thanks...

July 30, 2013
On Tuesday, 30 July 2013 at 14:31:00 UTC, Kenji Hara wrote:
> I think it's a not good compiler implementation detail and unnecessary
> intrusive behavior.
> Now I'm proposing to fix import mechanism in here.
> https://github.com/D-Programming-Language/dmd/pull/2256


That I agree. My comment referred to the opinion that having two identical imports in the same scope should not compile anyway, whatever the actual reason is.
July 30, 2013
On Tuesday, 30 July 2013 at 14:42:47 UTC, Dicebot wrote:
> On Tuesday, 30 July 2013 at 14:31:00 UTC, Kenji Hara wrote:
>> I think it's a not good compiler implementation detail and unnecessary
>> intrusive behavior.
>> Now I'm proposing to fix import mechanism in here.
>> https://github.com/D-Programming-Language/dmd/pull/2256
>
>
> That I agree. My comment referred to the opinion that having two identical imports in the same scope should not compile anyway, whatever the actual reason is.

To clarify even more: I consider it a mistake that identical imports are allowed even for "normal" imports but that can't be changed. At least specialized ones can be kept clean.
July 30, 2013
On Tuesday, 30 July 2013 at 14:42:47 UTC, Dicebot wrote:
> On Tuesday, 30 July 2013 at 14:31:00 UTC, Kenji Hara wrote:
>> I think it's a not good compiler implementation detail and unnecessary
>> intrusive behavior.
>> Now I'm proposing to fix import mechanism in here.
>> https://github.com/D-Programming-Language/dmd/pull/2256
>
>
> That I agree. My comment referred to the opinion that having two identical imports in the same scope should not compile anyway, whatever the actual reason is.

I would think that a redundant import would be something along the lines of a warning, not a full on error, there is no reason the compiler shouldn't be able to compile it.
July 30, 2013
On 07/30/2013 04:30 PM, Kenji Hara wrote:
> 2013/7/30 Dicebot <public@dicebot.lv <mailto:public@dicebot.lv>>
>
>     On Tuesday, 30 July 2013 at 12:29:00 UTC, Daniel Murphy wrote:
>
>         Please file a bug report: http://d.puremagic.com/issues/
>
>
>     I don't think it is a bug, enhancement request for error message at
>     most.
>
>
> Currently selective import *implicitly* creates alias declaration for
> each picked up names, and two equivalent selective import will make two
> alias declarations implicitly, then they conflict each other.
>
> import std.conv : to;
> import std.conv : to;
>
> is mostly same as:
>
> import std.conv;
> alias to = std.conv.to;
> alias to = std.conv.to;  // conflict with the first alias
>
> I think it's a not good compiler implementation detail and unnecessary
> intrusive behavior.
> Now I'm proposing to fix import mechanism in here.
> https://github.com/D-Programming-Language/dmd/pull/2256
>
> Kenji Hara

I think that the two alias declarations should simply not conflict.
July 30, 2013
On Tuesday, 30 July 2013 at 14:52:52 UTC, Tofu Ninja wrote:
> I would think that a redundant import would be something along the lines of a warning, not a full on error, there is no reason the compiler shouldn't be able to compile it.

That is somewhat similar to "statement has no effect" error. Any warning that has no valid use case should be an error, it does not matter if compiler can do it.
July 30, 2013
"Dicebot" <public@dicebot.lv> wrote in message news:ghodlivqehfqkvxsisgf@forum.dlang.org...
> On Tuesday, 30 July 2013 at 14:52:52 UTC, Tofu Ninja wrote:
>> I would think that a redundant import would be something along the lines of a warning, not a full on error, there is no reason the compiler shouldn't be able to compile it.
>
> That is somewhat similar to "statement has no effect" error. Any warning that has no valid use case should be an error, it does not matter if compiler can do it.

The use case is generated code.  Errors are for things that can cause bugs. How can identical imports cause a bug?


July 30, 2013
On Tuesday, 30 July 2013 at 15:11:53 UTC, Dicebot wrote:
> On Tuesday, 30 July 2013 at 14:52:52 UTC, Tofu Ninja wrote:
>> I would think that a redundant import would be something along the lines of a warning, not a full on error, there is no reason the compiler shouldn't be able to compile it.
>
> That is somewhat similar to "statement has no effect" error. Any warning that has no valid use case should be an error, it does not matter if compiler can do it.

I think the op is a valid use case, being able to have a mixin that imports what it needs regardless if it has been imported already or not.
July 30, 2013
On Tuesday, 30 July 2013 at 14:42:47 UTC, Dicebot wrote:
> That I agree. My comment referred to the opinion that having two identical imports in the same scope should not compile anyway, whatever the actual reason is.

I was positive that it is intended behaviour that multiple imports do not cause an error... It says this at http://dlang.org/pretod.html#pragmaonce:

"...D does a symbolic include of import files; they only get imported once no matter how many times the import declaration appears."

Thus, I'd expect "import std.conv: to; import std.conv: to" to compile.
July 30, 2013
On Tue, Jul 30, 2013 at 04:58:34PM +0200, Timon Gehr wrote:
> On 07/30/2013 04:30 PM, Kenji Hara wrote:
[...]
> >Currently selective import *implicitly* creates alias declaration for each picked up names, and two equivalent selective import will make two alias declarations implicitly, then they conflict each other.
> >
> >import std.conv : to;
> >import std.conv : to;
> >
> >is mostly same as:
> >
> >import std.conv;
> >alias to = std.conv.to;
> >alias to = std.conv.to;  // conflict with the first alias
> >
> >I think it's a not good compiler implementation detail and
> >unnecessary intrusive behavior.
> >Now I'm proposing to fix import mechanism in here.
> >https://github.com/D-Programming-Language/dmd/pull/2256
> >
> >Kenji Hara
> 
> I think that the two alias declarations should simply not conflict.

If the two aliases are aliasing the same thing, then they shouldn't conflict. This should be easy for the compiler to verify, right?


T

-- 
If Java had true garbage collection, most programs would delete themselves upon execution. -- Robert Sewell
1 2
Next ›   Last »