Classes
The concept of creating instances of classes with access to member variables and methods is common across languages.
Create a class with class start. It takes in, at the very least, the name of the class (in PascalCase as with functions). You can then also provide extends and a name of a class to indicate a single class to inherit from.
End it with class end.
1
class start : Word
2
comment line : ...
3
class end
4
​
5
class start : Noun extends Word
6
comment line : ...
7
class end
Copied!
In C#:
1
class Word
2
{
3
// ...
4
}
5
​
6
class Noun : Word
7
{
8
// ...
9
}
Copied!
In Python:
1
class Word:
2
# ...
3
​
4
class Noun(Word):
5
# ...
Copied!

Constructors

Constructors, or initialization methods, are called when a new instance of a class is created. It's declared with constructor start, which takes the publicity of the constructor, the name of the class, and any number of (name, type) arguments, and constructor end.
Inherited classes that define a constructor must provide an additional base argument along with any parameters to call to their parent class' constructor.
1
class start : Noun extends Word
2
constructor start : public Noun name string base
3
print : { concatenate : ("Creating ") name }
4
constructor end
5
class end
Copied!
In C#:
1
class Noun : Word
2
{
3
Noun(string name)
4
: base()
5
{
6
Console.WriteLine("Creating " + name);
7
}
8
}
Copied!
In Python:
1
class Noun(Word):
2
def __init__(self, name):
3
super().__init__()
4
print("Creating " + name)
Copied!

This

You can pass a reference to the current class using the this command.
1
this
Copied!
    In C#: this
    In Python: self

New

Create new instances of classes with the new command. It takes in the name of the class and any number of arguments to pass to the parameter.
1
variable : fruit Noun { new : Noun "apple" }
Copied!
    In C#: Noun fruit = new Noun("apple");
    In Python: fruit = Noun("apple")

Exports

You can export classes from the current file by including the export keyword before the class' name.
1
class start : export Word
2
comment line : ...
3
class end
Copied!
In C#:
1
public class Word
2
{
3
// ...
4
}
Copied!
In Python:
1
class Word:
2
// ...
Copied!
Last modified 1yr ago