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 typesT1
andT2
that both define a constructorC
, you need to specifyT1::C
orT2::C
by the type or type prefix in the context while using, otherwise the compiler will throw an error. -
New
UInt64
built-in type:
Added a built-inUInt64
type that supports addition, subtraction, multiplication, division, modulus, and conversion betweenUInt64
andInt64
.
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 aResult
type.
fn f() -> Int!String { .. }
fn main {
let res = f()!! // res: Result[Int, String]
println(res)
}
moon test
now 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
println
for I/O operations. Other operations will be provided in theio
package.
Core Update
-
Unified the function style for creating container objects, like
T::new()
/T::make()
, and removedT::with_capacity
. -
Renamed
iter
anditeri
toeach
andeachi
, anditer_rev
anditer_revi
toeach_rev
andeachi_rev
. -
Renamed
as_iter
toiter
.
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 --debug
in the JavaScript Debug Terminal for debugging. -
moon info
and coverage tools now accommodate error types and error handling.