Language Update
-
Enabled simplifying the type prefix for enum constructor:
When there is no ambiguity, you can omit the type prefix for enum constructors. For example, you can now writeSome(42)instead ofOption::Some(42). If there are two typesT1andT2that both define a constructorC, you need to specifyT1::CorT2::Cby the type or type prefix in the context while using, otherwise the compiler will throw an error. -
New
UInt64built-in type:
Added a built-inUInt64type that supports addition, subtraction, multiplication, division, modulus, and conversion betweenUInt64andInt64.
fn main {
let a = 0UL
let b : UInt64 = 1UL
println(a - b) //18446744073709551615
}
- Support for error handling with
!!suffix:
The semantics of the!!suffix have been modified to capture potential errors in function calls and return aResulttype.
fn f() -> Int!String { .. }
fn main {
let res = f()!! // res: Result[Int, String]
println(res)
}
moon testnow supports using error types to represent test failures. For example:
fn eq[T : Debug + Eq](a : T, b : T, ~loc : SourceLoc = _) -> Unit!String {
if a != b {
let a = debug_string(a)
let b = debug_string(b)
raise ("FAILED: \(loc) `\(a) == \(b)`")
}
}
test "test_eq" {
eq(1+2, 3)!
}
- The standard library now retains only
printlnfor I/O operations. Other operations will be provided in theiopackage.
Core Update
-
Unified the function style for creating container objects, like
T::new()/T::make(), and removedT::with_capacity. -
Renamed
iteranditeritoeachandeachi, anditer_revanditer_revitoeach_revandeachi_rev. -
Renamed
as_itertoiter.
Build System Update
- The build system will be open source this week.
Toolchain Update
-
Support for out-of-box debugging for better tooling experience. Users can now run
moon run --target js --debugin the JavaScript Debug Terminal for debugging. -
moon infoand coverage tools now accommodate error types and error handling.