Skip to content Luca Code icon Luca Code
Home Install First program Language guide Troubleshooting VS Code GitHub

Types and bindings

Scalars are int, dec, str, bool; uni accepts anything. none means “no value” and may sit in any binding.

def const name (str) = "Luca"
def var visits (int) = 1
def var inferred = "hello"      -- type inferred as str
visits (int) = visits + 1       -- update without changing type
def var x (int) = none
x.clear()                       -- mutable var back to none (error on const)
forget var x (int)              -- remove the binding entirely
change x (str) = "hi"           -- change a var's type and value

Expressions and operators

Decimals are exact (no binary floats): 20.00 + 1.50 displays 21.50. Division is numeric: 10 / 4 → 2.5 (dec).

Highest first. Parentheses override.
LevelOperatorsNotes
1not, unary -not needs bool
2* / %Division / modulo by zero is an error
3+ -String + needs str + str only
4is == to … is <= toWorded comparisons, exact forms
5and, then orBoth need bool, short-circuit
print(10 / 4)                    -- 2.5 (dec)
print(2.50 * 2.00)               -- 5.00
if name is == to "Luca" then :
    print("Hello, {name}!")
print(true and false)            -- false
print(x is == to none)           -- absence check

Control flow

Blocks use : plus consistent indentation. Empty blocks are errors. Conditions must be bool.

if visits is > to 1 then :
    print("Welcome back, {name}!")
else if visits is == to 1 then :
    print("Welcome!")
else :
    print("Hello.")

for 3 times repeat :
    print("hi")

for item from names repeat :
    print(item)

while visits is > to 0 then :
    visits (int) = visits - 1
    if visits is == to 0 then :
        stop              -- exits the innermost loop
    skip                  -- skips to the next iteration

Functions

Defaults, closures, recursion — and strict argument counts.

def func greet(name (str) = "Luca") (str):
    return "Hello, {name}!"

print(greet())
print(greet("Alex"))

Collections

1-based indexing, content equality, and warnings — never silent corruption.

def list names (str) = ["Luca", "Alex"]
def tuple data (uni) = (123, true, "Luca")
def set labels (str) = {"alpha", "stable"}
def dict person = {"Name" = "Luca" (str), "Age" = 16 (int)}

print(names[1])                 -- 1-based: "Luca"
names.add("Sam")
print(names.length)             -- item count
print(names.contains("Luca"))   -- true
change names[1] = "Lucca"
person.add("City", "Oslo")
print(person["Name"])

Modules

Real namespaces, own scopes, once-only init.

import Math
import Utils

print(Math.sqrt(25))
Utils.helper()

Errors and warnings

Errors stop execution unless captured. Warnings are nonfatal and never captured.

try to :
    File.read("data.txt")
capture error :
    print("Could not read the file.")
finally :
    print("Cleanup")

Custom errors with raise

def error NotFound :
    code = 404
    message = "missing"

raise NotFound()
raise NotFound(code = 410)

try to :
    raise NotFound()
capture error :
    print(error["code"])      -- 404
    print(error["message"])   -- missing

Input and the standard library

The binding’s declared type controls conversion; invalid input is an error you can capture.

def const name (str) = ask "What is your name?"
def const age (int) = ask "How old are you?"
print("Hello, {name}. You are {age}.")
Import first: import Math, import Text, import File, import System.
ModuleCallsNotes
Mathsqrt · pow · abs · round · floor · ceil · min · maxsqrt/pow → dec; round/floor/ceil → int; min/max take 2+ numerics
Textupper · lower · trim · replace · split · joinsplit(text, sep) → list(str); join(list, sep) → str
Fileread · write · append · exists · deleteRelative paths resolve against the working directory; missing delete warns, other failures error
Systemos · arch · args() · env() · exit(int)os/arch are bare reads; args() → list(str); exit flushes output, runs finally

Current boundary: everything locked for 1.0 Beta is implemented — all types, I/O, collections, functions, control flow, modules, custom-error raising and inspection, the four library modules, and CLI integration (exit codes, System.args wiring, .lucc enforcement).

Docs

Resources

© 2026 Luca Ecosystem · Luca Code 1.0 Beta.