All news

Published

Jik v0.1.0-alpha.18

Jik v0.1.0-alpha.18 is now available. This release makes ordinary struct-related functions more pleasant to call, completes try propagation for calls without a result, and adds useful standard-library helpers.

Uniform function calls for structs

A function defined alongside a struct can now be called through a value of that struct when its first parameter is explicitly annotated with the struct type. This is method-like syntax for an ordinary function call: the receiver becomes the first argument. Calls can also be naturally chained when a function returns another struct value.


struct Vec2:
    x: double
    y: double
end

func scale(v: Vec2, fact: double, r: Region) -> Vec2:
    return Vec2{x = v.x * fact, y = v.y * fact}[r]
end

func squared_norm(v: Vec2) -> double:
    return v.x * v.x + v.y * v.y
end

func main():
    v := Vec2{x = 3.0, y = 4.0}
    norm := v.scale(2.0).squared_norm() // 100
end

Propagate failures from calls without results

In a throws func, try can now propagate a throwing call that does not return a value. If the call fails, the enclosing function returns through its error path; otherwise execution continues normally.

throws func save_record(record):
    try write_record(record)
    println("saved")
end

New library helpers and module fixes

The standard library now includes path::normalize for lexical path normalization and string::compare for lexicographic string comparison. The release also fixes module-import aliases, so importing the same file under different aliases consistently refers to the same module symbols and types.