www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - private selective imports

reply "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
Is there any way to make selective imports private? I've got a 
name clash from importing an "all" module that has a bunch of 
public imports, one of which is circular, it goes sort of like 
this:

module math.all;

public:
import geometry;
import vectors;

---

module vectors;

struct Vector {}

---

module geometry;

import math.all: Vector;

And then I get an error like: vectors.Vector conflicts with 
geometry.Vector

Its the same Vector, though. What can I do?
Aug 06 2014
next sibling parent "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Wed, Aug 06, 2014 at 06:19:34PM +0000, Vlad Levenfeld via
Digitalmars-d-learn wrote:
 Is there any way to make selective imports private? I've got a name
 clash from importing an "all" module that has a bunch of public
 imports, one of which is circular, it goes sort of like this:
 
 module math.all;
 
 public:
 import geometry;
 import vectors;
 
 ---
 
 module vectors;
 
 struct Vector {}
 
 ---
 
 module geometry;
 
 import math.all: Vector;
 
 And then I get an error like: vectors.Vector conflicts with geometry.Vector
 
 Its the same Vector, though. What can I do?
I'd file a bug. But obviously, you want a workaround in the meantime. I'll leave it to the module experts to answer that. ;-) (My module structures tend to be quite shallow and simple, so I haven't run into this problem myself yet.) T -- If you want to solve a problem, you need to address its root cause, not just its symptoms. Otherwise it's like treating cancer with Tylenol...
Aug 06 2014
prev sibling parent reply "Dicebot" <public dicebot.lv> writes:
Most voted DMD bug : https://issues.dlang.org/show_bug.cgi?id=314
Aug 06 2014
next sibling parent "sigod" <sigod.mail gmail.com> writes:
On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote:
 Most voted DMD bug : 
 https://issues.dlang.org/show_bug.cgi?id=314
+1 vote from me.
Aug 06 2014
prev sibling next sibling parent "Gary Willoughby" <dev nomad.so> writes:
On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote:
 Most voted DMD bug : 
 https://issues.dlang.org/show_bug.cgi?id=314
Yeah this is a famous bug that seems to catch everyone out at some stage.
Aug 06 2014
prev sibling next sibling parent "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote:
 Most voted DMD bug : 
 https://issues.dlang.org/show_bug.cgi?id=314
+1 from me as well. This is unfortunate. D otherwise has a very comfortable import system.
Aug 06 2014
prev sibling parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote:
 Most voted DMD bug : 
 https://issues.dlang.org/show_bug.cgi?id=314
Yeah, it's why I'd suggest that folks not use selective imports right now. But people seem to really love the feature, so they use it and keep running into this problem. - Jonathan M Davis
Aug 06 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Wednesday, 6 August 2014 at 19:31:04 UTC, Jonathan M Davis 
wrote:
 On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote:
 Most voted DMD bug : 
 https://issues.dlang.org/show_bug.cgi?id=314
Yeah, it's why I'd suggest that folks not use selective imports right now. But people seem to really love the feature, so they use it and keep running into this problem. - Jonathan M Davis
scope-local selective imports are not affected
Aug 06 2014
parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Wednesday, 6 August 2014 at 19:35:02 UTC, Dicebot wrote:
 On Wednesday, 6 August 2014 at 19:31:04 UTC, Jonathan M Davis 
 wrote:
 On Wednesday, 6 August 2014 at 18:33:23 UTC, Dicebot wrote:
 Most voted DMD bug : 
 https://issues.dlang.org/show_bug.cgi?id=314
Yeah, it's why I'd suggest that folks not use selective imports right now. But people seem to really love the feature, so they use it and keep running into this problem. - Jonathan M Davis
scope-local selective imports are not affected
Sure, but people keep using them at the module-level, which really shouldn't be done until the bug is fixed. IMHO, we'd be better off making it illegal to use selective imports at the module-level rather than keeping it as-is. - Jonathan M Davis
Aug 06 2014
parent reply "Vlad Levenfeld" <vlevenfeld gmail.com> writes:
 Sure, but people keep using them at the module-level, which 
 really shouldn't be done until the bug is fixed. IMHO, we'd be 
 better off making it illegal to use selective imports at the 
 module-level rather than keeping it as-is.

 - Jonathan M Davis
I'm curious, what's the problem with it anyway? Judging by the posts in the bug report and the bug's own lifespan this must be a real tough one to crack.
Aug 06 2014
parent reply "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Wed, Aug 06, 2014 at 10:07:53PM +0000, Vlad Levenfeld via
Digitalmars-d-learn wrote:
Sure, but people keep using them at the module-level, which really
shouldn't be done until the bug is fixed. IMHO, we'd be better off
making it illegal to use selective imports at the module-level rather
than keeping it as-is.

- Jonathan M Davis
I'm curious, what's the problem with it anyway? Judging by the posts in the bug report and the bug's own lifespan this must be a real tough one to crack.
My guess is that it requires knowledge of dmd internals that only few people have, and those few people have other fires to put out right now. T -- Be in denial for long enough, and one day you'll deny yourself of things you wish you hadn't.
Aug 06 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Wednesday, 6 August 2014 at 22:24:24 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:
 My guess is that it requires knowledge of dmd internals that 
 only few
 people have, and those few people have other fires to put out 
 right now.
Kenji has a PR with new symbol overload resolution system that fixes it but Walter disagrees with proposed rules - at least that was the last state of this PR when I checked.
Aug 06 2014
parent "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Wed, Aug 06, 2014 at 10:55:14PM +0000, Dicebot via Digitalmars-d-learn wrote:
 On Wednesday, 6 August 2014 at 22:24:24 UTC, H. S. Teoh via
 Digitalmars-d-learn wrote:
My guess is that it requires knowledge of dmd internals that only few
people have, and those few people have other fires to put out right
now.
Kenji has a PR with new symbol overload resolution system that fixes it but Walter disagrees with proposed rules - at least that was the last state of this PR when I checked.
So the way to proceed is to discuss overload resolution rules that Walter agrees with, then? T -- Without outlines, life would be pointless.
Aug 06 2014