previous | start | next

What is an instance?

Herman writes an example. What does the following say about foo?

f = new foo()

Waldemar proposes we keep the same syntax as now. Herman asks what will typeof return when applied to f.

Perhaps the programmer started with:

function foo( )

and decided to change the code to define foo as:

class foo
{
}

typeof on f would now return foo rather than object

Herman now asks:

f instanceof Object

what about:

f.valueOf()

Waldemar asserts all objects are instances of Object. When applicable new objects support the same things as old ones.

Where is the prototype chain etc. for new kinds of objects?

f = new foo()

bar.prototype = f;

bar.prototype = foo;

Waldemar writes up:

class foo
{
   method m()
   {
   }

   slot a;
}

f = new foo();  // foo has a method m

function bar()
{
  ...
}

bar.prototype = f;

var g = new bar();

var foo x;

// the following generate errors
x = g;  // g is of type f not foo
g.m();  // f doesn't define m()

// but this works (why?)
g.a; // value of slot a of foo

Herman wonders why don't we take a leaf out of Java's book.

class foo
{
 ...
}

x = foo.class;  // the class object for foo
x = foo;        // the prototype of foo

The above deals with prototype based instances of new style classes. How valuable is this? Do we want to punt, if so where?

We agree that there is something worth exploring here. Can we find a solution that fits existing the expectations of existing users. Herman wonders about package private/public default and how that effects this topic.

Herman will write up a detailed proposal for review at the April meeting.



previous | start | next