Language Update
- A new syntax
T?
has been added for type annotations to representOption[T]
.
struct Cell[T] {
val: T
next: Cell[T]?
}
fn f(x : Cell[T]?) -> Unit { ... }
This is equivalent to
struct Cell[T] {
val: T
next: Option[Cell[T]]
}
fn f(x : Option[Cell[T]]) -> Unit { ... }
The old Option[T]
is still compatible, but it is recommended to use the shorter new syntax. moonfmt will also format Option[T]
as T?
.
- The core library API restructuring continues
- The Iter package has been merged into the builtin package. Now
Iter[T]
can be used without the@iter.
prefix.
- The Iter package has been merged into the builtin package. Now
pub fn any[T](xs : Iter[T], predicate : (T) -> Bool) -> Bool {
// ^no @iter. is required
match xs.find_first(predicate) {
None => false
Some(_) => true
}
}
-
The
Stack
package has been moved tomoonbitlang/x
. -
The List package has been removed, along with the
to_list
andfrom_list
functions for various data structures. It is recommended to useIter[T]
andArray[T]
for data structure conversion and intermediate representation. -
Performance improvements
- The compiler will now perform partial closure conversion during the separate compilation phase, improving compilation performance. Closure conversion has also been applied to code generated for the JavaScript backend in specific situations.
- The types
Option[Bool]
,Option[Char]
,Option[Byte]
, andOption[Unit]
are now represented using 32-bit integers, whereNone
is represented by -1 andSome(x)
byx
. The typeOption[Int]
is represented by a 64-bit integer in the wasm backend, whereNone
is represented by0x1_0000_0000
, andSome(x)
byx
. In the JavaScript backend,Option[Int]
is represented asint | undefined
, whereundefined
representsNone
.
-
abort
behavior change- To remove the dependency of Wasm programs on the non-standard
spectest.print_char
, the error output functionality is being restructured. abort
will no longer usespectest.print_char
to print error messages. Its behavior will be the same aspanic
until the functionality is further improved.
Plugin Update
- To remove the dependency of Wasm programs on the non-standard
-
[Language Server] Fixed a memory leak issue.