What's New in v1.15
"The Payloads Release" — two correctness fixes that remove long-standing sharp edges: any scalar can now ride inside an Option or Result, and your function names no longer collide with the C standard library.
It's all backward compatible — no source changes are required to upgrade.
Highlights
float?/bool?andResult<float, _>/Result<bool, _>now compile — previously onlyintandstringpayloads worked.- Function names can shadow libc symbols —
connect,read,write,socket, and friends are now free to use.
Float and Bool Optionals and Results
Before v1.15, only int and string payloads worked inside an Option or Result — a -> float? function wouldn't compile. Now every scalar works, in every position:
fn half(x: float) -> float? {
if x < 0.0 { return None }
return Some(x / 2.0)
}
fn divide(a: float, b: float) -> Result<float, string> {
if b == 0.0 { return Err("division by zero") }
return Ok(a / b)
}You can match on them in both statement and expression position:
match half(9.0) {
Some(v) => println("half is ${v}"), // half is 4.5
None => println("negative input"),
}
var result = divide(10.0, 4.0)
var msg = match result {
Ok(v) => "quotient ${v}",
Err(e) => "error: ${e}",
}
println(msg) // quotient 2.5The method API works too — .is_some(), .unwrap(), and .unwrap_or(default):
var maybe = half(8.0)
if maybe.is_some() {
println("got ${maybe.unwrap()}") // got 4.0
}
println(half(-1.0).unwrap_or(0.0)) // 0.0Booleans behave the same way:
fn parse_flag(s: string) -> bool? {
if s == "on" { return Some(true) }
if s == "off" { return Some(false) }
return None
}
match parse_flag("on") {
Some(v) => println("flag is ${v}"), // flag is true
None => println("unknown flag"),
}Function Names Can Shadow libc Symbols
A function named connect, read, write, open, close, socket, send, listen, index, and many others used to fail to compile with a cryptic C error (static declaration of 'connect' follows non-static declaration). Those names are now free to use — the generated C is transparently namespaced, so your Wyn code is completely unaffected:
fn connect(host: string) -> string {
return "connected to ${host}"
}
fn read(n: int) -> int {
return n + 1
}
fn main() {
println(connect("localhost")) // connected to localhost
println(read(41)) // 42
}Pick the name that reads best for your domain — the compiler handles the rest.
Upgrading
wyn --version # 1.15.0No source changes are required — v1.15.0 is a drop-in upgrade over v1.14.0.
See also
- What's New in v1.14 — the Polish Release
- What's New in v1.13 — the Pythonic Release
- Error Handling — Result and Option in depth
- Version History