www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Package attribute oops

reply Georg Wrede <georg.wrede nospam.org> writes:
Oh oh!

The followin hit me:

 Reading this I am trying to implement following:

 There are two modules
 --------------------
 module foo;

 class Foo {
     package int dummy;
 }

 --------------------

What's wrong here? Skimming real fast, I momentarily thought there is a package somewhere, called dummy. Of course, if one knows the language, then it is obvious it is a protection attribute for this int variable called dummy. ---- Got me thinking. If "package" is ok, then why don't we have "class", "file", "module", "program", "dll"..... protection attributes? So the word "package" is unsymmetric. Should we rename it? Would the word "package" be better reserved for later use, possibly similar to the word "module"?
Apr 02 2005
parent reply Mike Parker <aldacron71 yahoo.com> writes:
Georg Wrede wrote:

 So the word "package" is unsymmetric. Should we rename it?

I don't see why. 'package protection' is the phrase commonly used in the Java world to refer to the default protection level (i.e. the absence of public/protected/private). The package keyword in D makes perfect sense to me: this item is visible to other modules in the same package. I see your point in that it's a noun akin to class/module, and not an adjective as public/protected/private. But it did take a multitude of requests to get the feature into the language and I do recall a positive reaction when Walter first announced it (in regards to the keyword itself as well as the feature). Since one need not declare packages in D, it seems an acceptable keyword to me.
Apr 02 2005
parent reply Kevin VR <azra pandora.be> writes:
To me it sounds more logical to call it "packaged" in stead of 
"package", because "public", "private" and "protected" are all 
adjectives and "package" is a noun.
I'm not a native english speaker though, so i'm not really sure...

public/private/protected/packaged

Mike Parker wrote:
 Georg Wrede wrote:
 
 So the word "package" is unsymmetric. Should we rename it?

I don't see why. 'package protection' is the phrase commonly used in the Java world to refer to the default protection level (i.e. the absence of public/protected/private). The package keyword in D makes perfect sense to me: this item is visible to other modules in the same package. I see your point in that it's a noun akin to class/module, and not an adjective as public/protected/private. But it did take a multitude of requests to get the feature into the language and I do recall a positive reaction when Walter first announced it (in regards to the keyword itself as well as the feature). Since one need not declare packages in D, it seems an acceptable keyword to me.

Apr 02 2005
parent "Walter" <newshound digitalmars.com> writes:
"Kevin VR" <azra pandora.be> wrote in message
news:d2n82u$16rc$1 digitaldaemon.com...
 To me it sounds more logical to call it "packaged" in stead of
 "package", because "public", "private" and "protected" are all
 adjectives and "package" is a noun.

We could always call it 'static' <grins>.
Apr 03 2005