www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - private module declarations

reply Tom <ihate spam.com> writes:
I know this is not the first time this comes into the light but... I insist.

Actually (luckily), one can do the following:

bar.d
| class Bar {...whatever...} // Aux object

foo.d
| private import bar; // Private could be omitted
|
| class Foo {...whatever...}

main.d
| import foo;
|
| void main()
| {
|   Foo f = new Foo;
|   Bar b = new Bar; // Error, private imported in foo.d
|   ...

What are the difficulties of implementing in the language the following?

foo.d
| private class Bar {...whatever...} // Aux object
| class Foo {...whatever...}

main.d
| import foo;
|
| void main()
| {
|   Foo f = new Foo;
|   Bar b = new Bar; // Error, private member of foo.d
|   ...

I would love to see this someday.

Regards,
--
Tom;
"Some things have to be believed to be seen."
Aug 06 2006
next sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Tom" <ihate spam.com> wrote in message 
news:eb60uq$7eo$1 digitaldaemon.com...
 What are the difficulties of implementing in the language the following?

 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...

 I would love to see this someday.
I would absolutely love to see this. I mean, private module members already exist - but only for variables and functions. I've always wanted to be able to make aggregate types private to a module.
Aug 06 2006
prev sibling next sibling parent Derek Parnell <derek nomail.afraid.org> writes:
On Sun, 06 Aug 2006 21:19:35 -0300, Tom wrote:

 I know this is not the first time this comes into the light but... I insist.
 
 Actually (luckily), one can do the following:
 
 bar.d
| class Bar {...whatever...} // Aux object
 
 foo.d
| private import bar; // Private could be omitted
|
| class Foo {...whatever...}
 
 main.d
| import foo;
|
| void main()
| {
|   Foo f = new Foo;
|   Bar b = new Bar; // Error, private imported in foo.d
|   ...
 
 What are the difficulties of implementing in the language the following?
 
 foo.d
| private class Bar {...whatever...} // Aux object
| class Foo {...whatever...}
 
 main.d
| import foo;
|
| void main()
| {
|   Foo f = new Foo;
|   Bar b = new Bar; // Error, private member of foo.d
|   ...
 
 I would love to see this someday.
Makes a lot of sense to me too. What is fundamentally different about classes and structs, and every other type of declaration when it comes to visibility/accessibility? I'm sure this is a hang over from "the way C++ does it" mentality. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocrity!" 7/08/2006 1:08:40 PM
Aug 06 2006
prev sibling next sibling parent reply Sean Kelly <sean f4.ca> writes:
Tom wrote:
 I know this is not the first time this comes into the light but... I 
 insist.
 
 Actually (luckily), one can do the following:
 
 bar.d
 | class Bar {...whatever...} // Aux object
 
 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}
 
 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...
 
 What are the difficulties of implementing in the language the following?
 
 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}
 
 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...
 
 I would love to see this someday.
I thought it already worked this way, as I use the technique quite a bit :-p Ah well, I vote for it too then. Sean
Aug 06 2006
next sibling parent reply kris <foo bar.com> writes:
Sean Kelly wrote:
 Tom wrote:
 
 I know this is not the first time this comes into the light but... I 
 insist.

 Actually (luckily), one can do the following:

 bar.d
 | class Bar {...whatever...} // Aux object

 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...

 What are the difficulties of implementing in the language the following?

 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...

 I would love to see this someday.
I thought it already worked this way, as I use the technique quite a bit :-p Ah well, I vote for it too then. Sean
Count me too;
Aug 06 2006
parent reply Dave <Dave_member pathlink.com> writes:
kris wrote:
 Sean Kelly wrote:
 Tom wrote:

 I know this is not the first time this comes into the light but... I 
 insist.

 Actually (luckily), one can do the following:

 bar.d
 | class Bar {...whatever...} // Aux object

 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...

 What are the difficulties of implementing in the language the following?

 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...

 I would love to see this someday.
I thought it already worked this way, as I use the technique quite a bit :-p Ah well, I vote for it too then. Sean
Count me too;
Ditto.
Aug 07 2006
parent reply Chris Nicholson-Sauls <ibisbasenji gmail.com> writes:
Dave wrote:
 kris wrote:
 
 Sean Kelly wrote:

 Tom wrote:

 I know this is not the first time this comes into the light but... I 
 insist.

 Actually (luckily), one can do the following:

 bar.d
 | class Bar {...whatever...} // Aux object

 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...

 What are the difficulties of implementing in the language the 
 following?

 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...

 I would love to see this someday.
I thought it already worked this way, as I use the technique quite a bit :-p Ah well, I vote for it too then. Sean
Count me too;
Ditto.
Tritto. (Is that even a word?) -- Chris Nicholson-Sauls
Aug 07 2006
parent Lars Ivar Igesund <larsivar igesund.net> writes:
Chris Nicholson-Sauls wrote:

 Dave wrote:
 kris wrote:
 
 Sean Kelly wrote:

 Tom wrote:

 I know this is not the first time this comes into the light but... I
 insist.

 Actually (luckily), one can do the following:

 bar.d
 | class Bar {...whatever...} // Aux object

 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...

 What are the difficulties of implementing in the language the
 following?

 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...

 I would love to see this someday.
I thought it already worked this way, as I use the technique quite a bit :-p Ah well, I vote for it too then. Sean
Count me too;
Ditto.
Tritto. (Is that even a word?)
Quatro? -- Lars Ivar Igesund blog at http://larsivi.net DSource & #D: larsivi
Aug 07 2006
prev sibling next sibling parent Ivan Senji <ivan.senji_REMOVE_ _THIS__gmail.com> writes:
Sean Kelly wrote:
 Tom wrote:
 I know this is not the first time this comes into the light but... I 
 insist.

 Actually (luckily), one can do the following:

 bar.d
 | class Bar {...whatever...} // Aux object

 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...

 What are the difficulties of implementing in the language the following?

 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...

 I would love to see this someday.
I thought it already worked this way, as I use the technique quite a bit :-p Ah well, I vote for it too then.
I knew it didn't work this way but use this technique in hope it will work one day.
Aug 07 2006
prev sibling parent Graham St Jack <grahams acres.com.au> writes:
Sean Kelly wrote:
 Tom wrote:
 I know this is not the first time this comes into the light but... I
 insist.

 Actually (luckily), one can do the following:

 bar.d
 | class Bar {...whatever...} // Aux object

 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...

 What are the difficulties of implementing in the language the following?

 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}

 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...

 I would love to see this someday.
I thought it already worked this way, as I use the technique quite a bit :-p Ah well, I vote for it too then. Sean
I also thought it worked this way. I want it too.
Aug 07 2006
prev sibling next sibling parent Oskar Linde <oskar.lindeREM OVEgmail.com> writes:
Tom wrote:
 I know this is not the first time this comes into the light but... I 
 insist.
 
 Actually (luckily), one can do the following:
 
 bar.d
 | class Bar {...whatever...} // Aux object
 
 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}
 
 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...
 
 What are the difficulties of implementing in the language the following?
 
 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}
 
 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...
 
 I would love to see this someday.
I would too. I have already been coding like this with the assumption that this is how it is going to work at some point in the future. It is after all the only thing that makes sense. /Oskar
Aug 08 2006
prev sibling parent Bruno Medeiros <brunodomedeirosATgmail SPAM.com> writes:
Tom wrote:
 I know this is not the first time this comes into the light but... I 
 insist.
 
 Actually (luckily), one can do the following:
 
 bar.d
 | class Bar {...whatever...} // Aux object
 
 foo.d
 | private import bar; // Private could be omitted
 |
 | class Foo {...whatever...}
 
 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private imported in foo.d
 |   ...
 
 What are the difficulties of implementing in the language the following?
 
 foo.d
 | private class Bar {...whatever...} // Aux object
 | class Foo {...whatever...}
 
 main.d
 | import foo;
 |
 | void main()
 | {
 |   Foo f = new Foo;
 |   Bar b = new Bar; // Error, private member of foo.d
 |   ...
 
 I would love to see this someday.
 
 Regards,
 -- 
 Tom;
 "Some things have to be believed to be seen."
Vote++ And just to clarify, any kind of 'access' should be checked for protection attributes, including (but not limited to) : new Bar() Bar b; Bar.func() // fail even if func is accessible class Barbee : Bar { } template(T : Bar) { } template(alias A : Bar) { } alias Bar Baz; It may take a while to implement them all, so they don't have to be implemented all at once (and likely shouldn't), it's the first two or three that are the most important. -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Aug 08 2006