wraith-lang/example.w

70 lines
1.1 KiB
OpenEdge ABL

interface Increments
{
Increment(): void;
}
struct YourStruct
{
yourInt: int;
IncrementOther<T: Increments>(other: T): void
{
other.Increment();
}
}
struct MyStruct
{
myInt: int;
myBool: bool;
yourStructReference: Reference<YourStruct>;
yourStruct: YourStruct;
Increment(): void
{
myInt = myInt + 1;
}
Decrement(): void
{
myInt = myInt - 1;
}
static MyFunction(input: int): int
{
return input * 2;
}
}
struct Program
{
static Main(): int
{
myStruct: MyStruct;
myReference: Reference<MyStruct>;
myInt: int;
myReference = alloc MyStruct;
myInt = MyStruct.MyFunction(2);
myStruct.myInt = myInt;
myStruct.Increment();
if (myStruct.myInt < 5)
{
myStruct.Increment();
}
else if (myStruct.myInt > 10)
{
myStruct.Decrement();
}
else
{
myStruct.myInt = 4;
}
return myStruct.myInt;
}
}