www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - make imports private by default

reply Tyro <ridimz_at yahoo.dot.com> writes:
I don't know about you guys but IMHO imports should be made private by 
default. On the grand scheme of things this is quite minuscule, however, 
I think it important to point out that a vast majority of conflicts are 
caused by the mere fact that imports are done publicly.

Most often when I import a  library module, I only want it to be made 
available only in the file into which I imported it. If I need it to be 
available to users of my code, I should then be required to state so 
explicitly.

Just my opinion.
Andrew Edwards
Sep 26 2004
next sibling parent Helmut Leitner <helmut.leitner wikiservice.at> writes:
Tyro wrote:
 
 I don't know about you guys but IMHO imports should be made private by
 default. On the grand scheme of things this is quite minuscule, however,
 I think it important to point out that a vast majority of conflicts are
 caused by the mere fact that imports are done publicly.
 
 Most often when I import a  library module, I only want it to be made
 available only in the file into which I imported it. If I need it to be
 available to users of my code, I should then be required to state so
 explicitly.
 
 Just my opinion.
 Andrew Edwards

I agree with you. If it is still possible at this state of development, I would even argue to make imports private by default and add a public keyword for the rare cases where this is needed. -- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Sep 26 2004
prev sibling next sibling parent Mike Swieton <mike swieton.net> writes:
On Sun, 26 Sep 2004 05:05:19 -0400, Tyro wrote:

 I don't know about you guys but IMHO imports should be made private by 
 default. On the grand scheme of things this is quite minuscule, however, 
 I think it important to point out that a vast majority of conflicts are 
 caused by the mere fact that imports are done publicly.
 
 Most often when I import a  library module, I only want it to be made 
 available only in the file into which I imported it. If I need it to be 
 available to users of my code, I should then be required to state so 
 explicitly.
 
 Just my opinion.
 Andrew Edwards

Aggreed, 100%. Always default to the least confusing behavior, don't pull in symbols from across the ocean ;) Mike Swieton __ You can tell the ideals of a nation by its advertisements. - Norman Douglas
Sep 26 2004
prev sibling next sibling parent "Matthew" <admin.hat stlsoft.dot.org> writes:
Agreed

"Tyro" <ridimz_at yahoo.dot.com> wrote in message
news:cj60p4$4m$1 digitaldaemon.com...
I don't know about you guys but IMHO imports should be made private by default.
On the grand scheme of things this is 
quite minuscule, however, I think it important to point out that a vast
majority of conflicts are caused by the mere 
fact that imports are done publicly.

 Most often when I import a  library module, I only want it to be made
available only in the file into which I imported 
 it. If I need it to be available to users of my code, I should then be
required to state so explicitly.

 Just my opinion.
 Andrew Edwards 

Sep 27 2004
prev sibling next sibling parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Tyro" <ridimz_at yahoo.dot.com> escribió en el mensaje 
news:cj60p4$4m$1 digitaldaemon.com...
|I don't know about you guys but IMHO imports should be made private by
| default. On the grand scheme of things this is quite minuscule, however,
| I think it important to point out that a vast majority of conflicts are
| caused by the mere fact that imports are done publicly.
|
| Most often when I import a  library module, I only want it to be made
| available only in the file into which I imported it. If I need it to be
| available to users of my code, I should then be required to state so
| explicitly.
|
| Just my opinion.
| Andrew Edwards

I agree, but I think once Walter spoke of consistency: all things in D are 
public by default, so making imports private would break consistency. That's 
what he said, makes sense, although (again) I agree with the proposal.

-----------------------
Carlos Santander Bernal 
Sep 27 2004
next sibling parent Benjamin Herr <ben 0x539.de> writes:
Carlos Santander B. wrote:
  > I agree, but I think once Walter spoke of consistency: all things in 
D are
 public by default, so making imports private would break consistency. That's 
 what he said, makes sense, although (again) I agree with the proposal.

Sep 27 2004
prev sibling parent reply "Bent Rasmussen" <exo bent-rasmussen.info> writes:
 I agree, but I think once Walter spoke of consistency: all things in D are
 public by default, so making imports private would break consistency. 
 That's

Yes consistency, that's what I thought. Kind of like it.
Sep 27 2004
parent Tyro <ridimz_at yahoo.dot.com> writes:
Bent Rasmussen wrote:
I agree, but I think once Walter spoke of consistency: all things in D are
public by default, so making imports private would break consistency. 
That's

Yes consistency, that's what I thought. Kind of like it.

I agree that consistency is fundamentally important in the language. However, if in keeping the "tradition" one introduces characteristics that are both unintuitive and problematic, then the tradition must be broken in favor of a more sophisticated solution. I would much rather feel somewhat inconsistent (a little less traditional) than having to hunt down bugs caused by importing someone else's library and plastering my code with "private import" when that is what I mean 99% of the time anyway.
Sep 27 2004
prev sibling next sibling parent clayasaurus <clayasaurus gmail.com> writes:
me too.

Tyro wrote:
 I don't know about you guys but IMHO imports should be made private by 
 default. On the grand scheme of things this is quite minuscule, however, 
 I think it important to point out that a vast majority of conflicts are 
 caused by the mere fact that imports are done publicly.
 
 Most often when I import a  library module, I only want it to be made 
 available only in the file into which I imported it. If I need it to be 
 available to users of my code, I should then be required to state so 
 explicitly.
 
 Just my opinion.
 Andrew Edwards

Sep 29 2004
prev sibling next sibling parent Derek Parnell <derek psych.ward> writes:
On Sun, 26 Sep 2004 05:05:19 -0400, Tyro wrote:

 I don't know about you guys but IMHO imports should be made private by 
 default. On the grand scheme of things this is quite minuscule, however, 
 I think it important to point out that a vast majority of conflicts are 
 caused by the mere fact that imports are done publicly.
 
 Most often when I import a  library module, I only want it to be made 
 available only in the file into which I imported it. If I need it to be 
 available to users of my code, I should then be required to state so 
 explicitly.
 
 Just my opinion.

It's hard to think of any overriding counter argument. The only thing I can come up with so far is that making imports default to private is inconsistent with member declarations, as these are public by default. In the meantime I guess we need to get into the habit of coding thus ... private{ import std.string; import std.stdio; import whatever.etc; } -- Derek Melbourne, Australia 30/09/2004 2:55:29 PM
Sep 29 2004
prev sibling parent Norbert Nemec <Norbert Nemec-online.de> writes:
I can only agree to this.

My personal experience from Python, where imports are public:

* you get the namespace clogged up extremely fast: Library coders just do
 from somewhere import *
for their own convenience, so anyone using the library has their namespaces
filled with stuff they don't need

* Very often, you loose track where a symbol actually came from, because
symbols can be imported from just about any module and you hardly ever stop
to think where the symbol was actually defined.

Just my personal experience. It is nice to go for consistency (like:
"everything is public by default") but it is much more important to think
about the consequences for the programmer, and in this case, it really is a
question of protecting the application programmer against the laziness
library programmer.

Ciao,
Nobbi



Tyro wrote:

 I don't know about you guys but IMHO imports should be made private by
 default. On the grand scheme of things this is quite minuscule, however,
 I think it important to point out that a vast majority of conflicts are
 caused by the mere fact that imports are done publicly.
 
 Most often when I import a  library module, I only want it to be made
 available only in the file into which I imported it. If I need it to be
 available to users of my code, I should then be required to state so
 explicitly.
 
 Just my opinion.
 Andrew Edwards

Oct 19 2004