[1236] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next next in chain last in chain last

Re: [COLD] public/private/protected object variables

daemon@ATHENA.MIT.EDU (Sat Mar 1 00:24:11 1997 )

From: "Jon A. Lambert" <jlsysinc@ix.netcom.com>
To: "COLD" <coldstuff@cold.org>
Date: Sat, 1 Mar 1997 00:22:32 -0500

> Back when I added public/private/protected methods I considered diong the
> same with variables.  Once again I'm considering it--simply because the
> need for such a beast is more and more becoming a need for some people. 
> What I'm thinking of implementing is three types of object variables.  We
> would still keep encapsulation in that only the definer can access
> variables and instances it defines.  What we would be expanding on is the
> default value for these instances (i.e. what is inherited and how). 
> Basically: 
>         private     -- act as they do now--if no instance is defined
>                        simply return zero.  This would be the default
>         protected   -- if there is no instance, use the _definers_
>                        instance (and only the definers)
>         public      -- get the first instance in the ancestor tree--using
>                        the same search requirements as for methods.  We
>                        would likely want a cache like with methods..or
> Comments?
Yes! Definitely!!

I think these are formally called class attributes in OO terminology.

If you are familiar with Smalltalk these are called "class variables".
In C++ they are called "static variables".

I believe that these could be EXTREMELY useful constructs.

I know the memory size of derived objects could be reduced in many 
circumstances.   It would also allow better encapsulation and might
even reduce the proliferation of unnecessary utility-object types.

Of course, I could be wrong.