Sunday, November 11, 2018

Inheritance with chakracore-delphi

I've just pushed some updates to chakracore-delphi.

A new feature worth mentioning is support for inheritance (I mean Javascript-style, "prototypical inheritance") in both directions. Suppose the following hierarchy:

First, here is Shape the "superclass", defined in Javascript:



Next comes Circle, a "subclass" of Shape, defined in Javascript as well:



The following is Rectangle, defined in Pascal, as a "subclass" of Shape:



Here's Square, defined in Javascript again, as a "subclass" of Rectangle:



And finally here are the tests, demonstrating that
- (Javascript) Circle descends from (Javascript) Shape
- (Pascal) Rectangle descends from (Javascript) Shape
- (Javascript) Square descends from (Pascal) Rectangle



As always, you can grab the latest code on GitHub. Cheers!

No comments: