Data Types
Primitive Types
Section titled “Primitive Types”| Type | Description | Example |
|---|---|---|
vacio | Absence of value. Used as return type for functions that don’t return a value. Cannot be used to declare variables. | - |
entero | 64-bit signed integers. | entero edad = 32 |
numero | Double precision decimal values. | numero temperatura = 21.5 |
texto | Unicode strings. | texto saludo = "Hola" |
log | Logical values verdadero or falso. | log habilitado = verdadero |
Lists can be typed or generic.
lista<texto> nombres = ["Ana", "Luis", "Maria"]lista valores = [1, "dos", verdadero]Mutable lists (lista<type> var) accept methods like agregar, insertar, quitar_en, ordenar, or sumar.
lista<entero> var numeros = [3, 1, 4]numeros.ordenar()consola.mostrar(numeros.texto()) // [1, 3, 4]JSON (jsn)
Section titled “JSON (jsn)”JSON objects are first-class and support dot access, key access, or auxiliary methods.
jsn var persona = { nombre: "Ana", datos: { edad: 28, ciudad: "Guatemala" }, telefonos: ["555-1234", "555-5678"], activo: verdadero}
texto ciudad = persona.datos.ciudadpersona.establecer("activo", falso)lista<texto> claves = persona.claves()Type Conversion
Section titled “Type Conversion”Values offer explicit conversion methods. If the operation is not possible, the interpreter throws a runtime error.
entero numero_entero = "123".entero()numero numero_decimal = "123.45".numero()log valor_logico = "verdadero".log()texto como_texto = numero_entero.texto()lista<entero> desde_texto = "1,2,3".lista()To convert lists or JSON to readable text:
lista<texto> palabras = ["Hola", "Quetzal"]texto representacion = palabras.texto() // "[Hola, Quetzal]"texto json_pretty = persona.texto_formateado()Null Values
Section titled “Null Values”The interpreter recognizes the nulo literal, which can be assigned to any type.
entero valor_entero_nulo = nulonumero valor_numero_nulo = nulotexto valor_texto_nulo = nulolog valor_logico_nulo = nulolista valores_lista_nula = nulolista<entero> valores_lista_tipada_nula = nulojsn valor_json_nulo = nuloWhen accessing a non-existent property in a jsn, the result is nulo. Check for key presence using contiene_clave before converting values or calling methods on them.
jsn datos = { nombre: "Ana" }log tiene_activo = datos.contiene_clave("activo")log es_activo = tiene_activo y (datos.activo == verdadero)