A Cicada class, or class instance, is nothing more than a composite variable having both members that are methods (functions).
myClass :: {
data :: int
moreData :: string
init :: {
code
{ data, moreData } = { 1, "blank" }
}
otherMethod :: { ... }
}
In a sense, all we have done is point out that functions such as init() can be defined inside of composite variables.
The init() function can be thought of as a constructor, since it initializes the class data. It might be more convenient to have that run automatically by taking it out of init():
myClass :: {
data :: int
moreData :: string
{ data, moreData } = { 1, "blank" }
otherMethod :: { ... }
}
Now myClass and any class instance myObject :: myClass begins initialized to { 1, "blank" }. We can even bundle the constructor code together with the member definitions:
myClass :: {
data := 1
moreData := "blank"
otherMethod :: { ... }
}
The constructors run when the object is created, but what if we need to rerun the constructor? Treating our object as a function, we just write:
myObject#0() | code #0 is the constructor
Code number 1 of a function, which is the default function code, begins after the first code marker or semicolon; therefore the constructor code, which is code number 0, comprises everything leading up to that first code marker. In the case of a class object, there is no code marker, so the constructor is everything inside of the curly braces.
There is no destructor in Cicada. In fact there isn’t even a direct way to delete an object -- we can only remove members leading to an object. Theoretically, when no more members point to an object, that object will be deleted. In practice Cicada doesn’t do this very well -- we can help it out using its springCleaning() function.
Last update: November 12, 2025