1
0
forked from Mirror/wren

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

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.**

View File

@ -51,7 +51,7 @@ Variables can be declared using `var`:
## Method calls
Wren is a deeply object-oriented language, so most code consists of method calls. They look pretty familiar:
Wren is object-oriented, so most code consists of method calls. They look like this:
:::wren
io.write("hello")

3
doc/site/usage.markdown Normal file
View File

@ -0,0 +1,3 @@
^title Usage
**TODO**

View File

@ -13,7 +13,7 @@ TEMPLATE = """
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>wren {title}</title>
<title>Wren - {title}</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link href='http://fonts.googleapis.com/css?family=Sanchez:400|Source+Sans+Pro:300,400,700,400italic,700italic|Source+Code+Pro:300,400' rel='stylesheet' type='text/css'>
</head>
@ -28,6 +28,7 @@ TEMPLATE = """
<li><a href="index.html">welcome</a></li>
<li><a href="syntax.html">syntax</a></li>
<li><a href="classes.html">classes</a></li>
<li><a href="usage.html">usage</a></li>
</ul>
</div>
</div>