[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

On Thu, May 10, 2001 at 01:04:32PM +0000, Robert Lemmen wrote:
> hi folks,
> 
> i am curretnly trying to get some things done in coldc, and there is something
> i don't understand:
> 
> 
> i saw some code like that
> 
> new object $ofenrohr: $pfannkuchen;
> var $ofenrohr schnickschnack;
> var $pfannkuchen zickezacke;
> 
> now what do the $ofenrohr and $pfannkuchen in the variable lines do?? as far as
> i understoof coldc variables as being private and not accessible by children,
> this doesn't make ay sense to me.
> 

The textdump format--while human readable--is not intended for general
consumption.  This is a caveat, before I begin :)

ColdC object variables are private, but each object can have an instance
of a variable defined by a parent, but only methods defined on the
same parent can access that variable.

For instance, say you have object $a, and object $b as a child of
object $a.  $a defines the obj var ,v1 and $b defines the object var
,v2.  This is OK, abiet confusing.  Furthermore, $b can have to
distinctly different values for ,v1--depending upon which object the
v1 variable is for.  If a method defined on $b references the v1
variable, it will pull the value from the v1 variable defined on
object $b (lets say 10).  And likewise a method defined on $a but
executed on $b will pull $b's instance of the v1 variable defined
by $a (lets say 20).  And the textdump formatted view of this would
be:

object $a: $root
var $a v1 = 0;

method .geta ( ) {
    return v1;
};

object $b: $a
var $a v1 = 20;
var $b v1 = 10;

method .getb ( ) {
    return v1;
};

And the following statements would all be true:

  $a.geta() => 0;
  $b.geta() => 20;
  $b.getb() => 10;

-Brandon