www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - "inner" keyword (for 2.0)

reply Id <Id_member pathlink.com> writes:
Since the "private" keyword also allows access to members in the same module,
what about adding (for 2.0) the keyword "inner" to specify an attribute that
behaves like Java's private?
(That is, an attribute that only the class itself can access).
Aug 30 2004
next sibling parent reply Ilya Minkov <minkov cs.tum.edu> writes:
Id schrieb:

 Since the "private" keyword also allows access to members in the same module,
 what about adding (for 2.0) the keyword "inner" to specify an attribute that
 behaves like Java's private?
 (That is, an attribute that only the class itself can access).
It was decided against such a restriction, because one module is probably maintained by the same person or a group of people, and if they really need to make nonsense within such a small scope... well, there is nothing that could possibly stop them. -eye
Aug 31 2004
parent =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= writes:
Also, it doesn't start with a "p" :p

Ilya Minkov wrote:
 Id schrieb:
 
 Since the "private" keyword also allows access to members in the same 
 module,
 what about adding (for 2.0) the keyword "inner" to specify an 
 attribute that
 behaves like Java's private?
 (That is, an attribute that only the class itself can access).
It was decided against such a restriction, because one module is probably maintained by the same person or a group of people, and if they really need to make nonsense within such a small scope... well, there is nothing that could possibly stop them. -eye
Aug 31 2004
prev sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"Id" <Id_member pathlink.com> wrote in message
news:ch05hl$2vgb$1 digitaldaemon.com...
 Since the "private" keyword also allows access to members in the same
module,
 what about adding (for 2.0) the keyword "inner" to specify an attribute
that
 behaves like Java's private?
 (That is, an attribute that only the class itself can access).
What would be nice is: to have inner classes (by this I mean a class nested in another class and whose objects can only be created from within the parent class and an object of this inner class holds implicitly a reference to its parent class. So something like class A { class B { this(A parent) { this.parent = parent; } A parent; } void func() { B b = new B(this); } } would be the same as: class A { inner class B { this(){} } void func() { B b = new B(); } }
Aug 31 2004