Skip to content

Flow Control

Ends a function and returns a value. In vacio type functions it can be omitted.

texto saludar(texto nombre) {
retornar t"Hola, {nombre}"
}

Object constructors do not allow retornar; the implicit value is always vacio.

Immediately exits the current loop (para, mientras, hacer ... mientras, or iterations with en/cada).

entero var contador = 0
mientras (contador < 10) {
si (contador == 5) {
romper
}
contador++
}

Skips the rest of the current block and evaluates the next loop iteration.

// Reserved word 'continuar', continues to the next loop iteration
para (entero var i = 0; i < 10; i++) {
si (i % 2 == 0) {
// If the number is even, skip printing and continue to next iteration
continuar
}
consola.mostrar(i)
}

Generates an exception that can be caught higher up in the call stack.

numero dividir(numero a, numero b) {
si (b == 0) {
lanzar "Division by zero"
}
retornar a / b
}

intentar, capturar, finalmente (try, catch, finally)

Section titled “intentar, capturar, finalmente (try, catch, finally)”

Handle exceptions generated within the intentar block. The capturar parameter must use the excepcion type.

intentar {
numero resultado = dividir(10, 0)
consola.mostrar(resultado.texto())
} capturar (excepcion error) {
consola.mostrar_error(error.mensaje)
} finalmente {
consola.mostrar("Operation finished")
}

The esperar keyword is reserved for future asynchronous function execution. In v0.0.2 it is not yet fully enabled.

The interpreter does not include explicit instructions like exit or quit. To finish, simply allow the program to reach the end of the file or use retornar at the entry point if your application is organized within a main function.

These tools, combined with conditionals and loops, allow you to control your programs’ behavior.