charly-lang / charly

🐈 The Charly Programming Language | Written by @KCreate
https://charly-lang.github.io/charly/
MIT License
199 stars 10 forks source link

Class Inheritance, Composition and Extension #32

Closed KCreate closed 7 years ago

KCreate commented 7 years ago

This builds on top of this issue. Syntax for composing different classes together to form a new one is as follows:

class Person {};
class SuperPowers {};
class TheFlash(Person, SuperPowers) {};

This just executes Person, SuperPower and TheFlash (in this order) in a shared stack.

To extend a class you write

class Person {};
class Person(Person) {};

Note that you have to be in the same scope as where the class was defined, as class definitions are block-scoped.

KCreate commented 7 years ago

Closed via #88