# The MoonBit Update——0304

**URL:** <https://discuss.moonbitlang.com/t/the-moonbit-update-0304/171>\
**Category:** Announcement\
**Tags:** weekly-update\
**Created:** [March 4, 2024, 10:47am UTC](https://discuss.moonbitlang.com/t/the-moonbit-update-0304/171 "2024-03-04T10:47:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jodie](https://discuss.moonbitlang.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@jodie](https://discuss.moonbitlang.com/u/jodie)\
**Post date:** [March 4, 2024, 10:47am UTC](https://discuss.moonbitlang.com/t/the-moonbit-update-0304/171/1 "2024-03-04T10:47:05Z")

</div>

# MoonBit Update

1. We added support for `+=` operators, including: `+=`, `=`, `=` and `/=`. You can use them to mutate the value of a mutable variable.

2. Toplevel declarations that are not left-aligned will be an error now.

 ![image](https://discuss.moonbitlang.com/uploads/default/original/1X/3cad1b8044807402dba6a1ee819964c9e8db06c5.png)

1. New language feature: Super Trait. A super trait can be specified using `:`, e.g.

2. We added`T::[x, y, ...]` as a short-hand notation for `T::from_array([x, y, ...])`, to provide a more handy way to initialize array-like structures, for example, a list.

3. `fn hello() = "xx"` has been deprecated. Instead, we suggest you write it as follows:

4. The logic of derived `Show` implementation is modified. It now uses `Debug` as implementation. So to derive `Show` for a type, users now need to implement or derive `Debug` for that type first. `Debug`’s output is valid MoonBit syntax for creating values, while `Show` can be used to produce better-looking output. This solves the problems of derived `Show` implementation with `String` fields:

5. Dropping non-unit values is now an error. Use `ignore` to explicitly discard them.

6. `test` is now a keyword, and cannot be used as an identifier anymore.

## IDE Update

1. Better support for Markdown in online IDE.

- MoonBit Code inside markdown will be highlighted.

 ![image](https://discuss.moonbitlang.com/uploads/default/original/1X/aac481a3ab66a705feeb1d5ae90efd0456d01cfe.png)

- We open-sourced a simple tools to check the syntax correctness of MoonBit code blocks in a markdown documentation at [GitHub - moonbitlang/moonbit-markdown: markdown linter for MoonBit · GitHub](https://github.com/moonbitlang/moonbit-markdown) . Refer to its README for usage.

## Build System Update

1. We support _the_ `main` function now. However, there are some caveats you might want to know
  1. It can only be in the `main` package (where `is_main: true`).
  2. The `main` package should have _exactly_ one `main` function.
  3. It will be executed after all `init` functions
  4. We disallow any `test`to co-exists with the `main` function inside the same package.

2. You can use `moon upgrade`to upgrade your MoonBit toolchain to the latest version. However, before using it, you must run the installation script one more time :-)
3. The `moon check|build|run` command now defaults to linking with the standard library `moonbitlang/core`.
