Work on docs a little bit.

This commit is contained in:
Bob Nystrom
2013-11-23 14:52:50 -08:00
parent e4b5613780
commit ba676f1231
4 changed files with 32 additions and 3 deletions
+26 -1
View File
@@ -1,3 +1,28 @@
^title Classes
**TODO**
Every value in Wren is an object, and every object is an instance of a class.
Even `true` and `false` are full-featured objects, instances of the `Bool` class.
## Defining a class
Classes are created using the `class` keyword, unsurprisingly:
:::wren
class Unicorn {}
This creates a class named `Unicorn` with no methods or fields.
**TODO: methods**
## Inheritance
A class can inherit from a "parent" or *superclass*. When you invoke a method on an object of some class, if it can't be found, it walks up the chain of superclasses looking for it there.
By default, any new class inherits from `Object`, which is the superclass from which all other classes ultimately descend. You can specify a different parent class using `is` when you declare the class:
:::class
class Pegasus is Unicorn {}
This declares a new class `Pegasus` that inherits from `Unicorn`.
**TODO metaclasses, supercalls, fields, etc.**