[825] in Coldmud discussion meeting

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

protected and private object variables

daemon@ATHENA.MIT.EDU (Sat Oct 14 00:22:54 1995 )

Date: Fri, 13 Oct 1995 22:17:43 -0600
From: 869683 Gillespie Brandon James <brandon@smithfield.declab.usu.edu>
To: coldstuff@pippin.ece.usu.edu

I've been thinking we should have protected and private object variables
Basically, a protected variable would be as it is now.  A private variable
would act a little differently.  Basically, it cannot be derived by a child,
but you can access it executing as a child with a method defined on the        
definer.  Best explained with an example:

-------------
object $foo;    
private var bar = [1,2,3];
protected var mybar = [];

public test {
    arg test;

    if (test in bar) 
        mybar = [@(mybar || []), test];
};

new object $foo_1: $foo;
-------------

From this, $foo_1,test starts as 0.  I call $foo_1.test(1), and $foo_1,test
becomes [1], because 'test in bar' gets the value of bar from $foo, rather
than from $foo_1, because it is a private variable.  If $foo_1 were to
define another method, and attempt to access bar, it would not work (just
as it should not).

Is this something I should add?

-Brandon