What's New in v1.12
v1.12 brings real closures, proper generics, and auto-derived methods.
Real Closures
Lambdas now properly capture variables from their enclosing scope. This works with .map(), .filter(), .reduce(), and return closures.
wyn
var nums = [1, 2, 3, 4, 5]
var factor = 10
var scaled = nums.map(|x| x * factor)
// scaled = [10, 20, 30, 40, 50]
var threshold = 3
var big = nums.filter(|x| x > threshold)
// big = [4, 5]Closure Factories
wyn
fn make_adder(x: int) -> fn(int) -> int {
return |y| x + y
}
var add5 = make_adder(5)
println(add5(10)) // 15Auto-derive to_string()
All structs automatically get a to_string() method:
wyn
struct Point { x: int, y: int }
var p = Point { x: 42, y: 99 }
println(p.to_string()) // Point(x=42, y=99)Proper Generic Type Equality
The type system now correctly distinguishes between different generic instantiations. List<int> and List<string> are properly recognized as different types.