Closed GoogleCodeExporter closed 9 years ago
I have found out that when writing
Rectangle.prototype = new Shape;
it goes OK. So this syntax allowed, while Object.create style is not. I suggest
it should be, as it's much better in many respects. The most common problem is
when Shape ctor would require some parameters, in which case writing just 'new
Shape' could throw, but often providing parameters could be difficult (if they
need to constructed using several lines of code) and messy. So the
Object.create way is much preferred. I believe it should also be supported for
extending structs, just like the 'new' syntax.
BTW the example is taken from:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
/Object/create
Original comment by closure....@gmail.com
on 19 Mar 2014 at 3:18
Closing this, as it's not related to @struct specifically. As you noticed, the
compiler doesn't support Object.create. Please file a separate issue for that
to be added to the type system.
Original comment by dim...@google.com
on 19 Mar 2014 at 4:45
Original issue reported on code.google.com by
closure....@gmail.com
on 19 Mar 2014 at 3:04