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
one option is to return object and offer a new typeof operator that deals with classes
another is for typeof to return the class object for foo rather than the string "foo".
we could spell the new typeof as:
f.getClass()
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.