class Main {
i : IO <- new IO;
main(): Object {
i.out_string("Hola Mundo")
};
};
class Main inherits IO{
i : IO <- new IO;
main(): Object {
self.out_string("Hola Mundo")
};
};
class Main {
main(): Object {
{
(new IO).out_string("Dame un numero:");
(new IO).in_string().concat("\n");
}
};
};
Para compilar con una libreria extra, hace falta añadirla a la linea de comandos.
Las variables se ponen dentro de un bloque.
let fact: Int <- 1 in
{
while (not (i=0)) loop
{
fact <- fact * i;
i <- i - 1;
}
pool;
fact;
}
Se pueden generar varias variables utilizando comas
class main inherits IO{
main(): Object{
let hello: String <- "Hello",
world: String <- "World",
newline: String <- "\n"
in
out_string(hello.concat(world.concat(newline)))
};
};
Se pueden definir varias clases en el mismo fichero:
class Lista{
item: String;
next: Lista;
init(i: String, n: Lista): Lista{
{
item <- i;
next <- Lista;
self;
}
};
to_string(): String
{
if (isvoid next) then item else item.concat(next.to_string()) fi
};
};
Se pueden definir varias clases en el mismo fichero:
class main inherits IO{
main(): Object{
let hello: String <- "Hello",
world: String <- "World",
newline: String <- "\n",
null: Lista,
l: Lista <- (new Lista).init(hello,
(new Lista).init(world,
(new Lista).init(newline,null)
))
in
out_string(l.to_string())
};
};