MoonBit更新
1. 新增矩陣函數(shù)的語法糖
新增矩陣函數(shù)的語法糖,用于方便地定義局部函數(shù)和具有模式匹配的匿名函數(shù):
fn init {
fn boolean_or { // 帶有模式匹配的局部函數(shù)
true, _ => true
_, true => true
_, _ => false
}
fn apply(f, x) {
f(x)
}
let _ = apply(fn { x => x + 1 }, 42) // 匿名函數(shù)
let _ = apply(fn { // 帶有模式匹配的匿名函數(shù)
0 => 0
1 => 1
_ => 2
}, 42)
}
2. 新增使用 T::{ ... }構(gòu)造結(jié)構(gòu)體的語法
這個(gè)新語法可用于顯式的指定結(jié)構(gòu)體的類型,并會(huì)使得結(jié)構(gòu)體內(nèi)有更好的補(bǔ)全:
struct T {
x: Int
y: Int
}
struct T2 {
x: Int
y: Int
}
fn init {
let x = T::{x: 1, y: 2}
debug(x.x + x.y) // 3
}
3. 正式移除 var id = expr 的語法
4. 增加了新的關(guān)鍵詞 test
新的測(cè)試語法 test "name" {}
,用于代替原先的fn test_name(){}
。目前暫時(shí)只有頂格縮進(jìn)的test
會(huì)被識(shí)別成關(guān)鍵字,未來將不再支持使用test
作為標(biāo)識(shí)符。
舊語法: fn test_
name
{}
新語法: test "
name
" {}
5. 支持在 init 或者 test 代碼塊中使用 return 語句
fn init {
if i > 0 {
return
}
...
}
test {
if i > 0 {
return
}
...
}
插件更新
改進(jìn)了語法高亮:
Before:
After:
mooncakes.io 更新
1. 新增 mooncakes.io 注冊(cè)方式
現(xiàn)在mooncakes.io 支持使用用戶名+郵箱方式注冊(cè),而不僅限于之前的GitHub登錄方式?,F(xiàn)在新用戶可以搶先注冊(cè)你心儀的用戶名。(注意:用戶名字符需要>=5,如果小于5需要聯(lián)系管理員后臺(tái)操作。)文章來源:http://www.zghlxwxcb.cn/news/detail-818051.html
$ moon register
Choose a way to register: Email
You chose: Email
Username: xxxxxx
Password: [hidden]
Email: xxxxxx@xxx.xx
Send verification code to your email[bzy_sustech@foxmail.com]? yes
Please input the verification code: xxxxxx
Register successfully!
API token saved in ~/.moon/credentials.json
2. 增加跳轉(zhuǎn)到源代碼的功能
文章來源地址http://www.zghlxwxcb.cn/news/detail-818051.html
到了這里,關(guān)于編程語言MoonBit新增矩陣函數(shù)的語法糖的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!