当前位置: 首页 > news >正文

文安做网站国内新闻最新消息

文安做网站,国内新闻最新消息,大连新图闻网站设计,重庆待遇好的互联网公司weekly 2024-08-05 MoonBit更新 JSON字面量支持array spread。 let xs: Array[json.JsonValue] [1, 2, 3, 4] let _: json.JsonValue [1, ..xs]增加了类型别名的支持,主要是为了渐进式代码重构和迁移,而不是某种给类型简短名字的机制。例如&#xf…

weekly 2024-08-05

MoonBit更新

  • JSON字面量支持array spread。
let xs: Array[@json.JsonValue] = [1, 2, 3, 4]
let _: @json.JsonValue = [1, ..xs]
  • 增加了类型别名的支持,主要是为了渐进式代码重构和迁移,而不是某种给类型简短名字的机制。例如,假设需要把 @stack.Stack 重命名为 @stack.T,一次性完成迁移需要修改大量使用 @stack.Stack 的地方,对于大项目很容易产生 conflict,如果有第三方包使用了 @stack.Stack,则会直接造成 breaking change。使用 type alias,则可以在重命名后留下一个 @stack.Stack 的 alias,使现有代码不会失效:
/// @alert deprecated "Use `T` instead"
pub typealias Stack[X] = T[X]

接下来,可以渐进式地逐步迁移对 @stack.Stack 的使用、给第三方用户时间去适配新的名字。直到迁移全部完成,再移除 type alias 即可。除了类型重命名,typealias 还可用于在包之间迁移类型定义等等

  • 增加了给 trait object 定义新的方法的支持:
trait Logger {write_string(Self, String) -> Unit
}trait CanLog {output(Self, Logger) -> Unit
}// 给 trait object 类型 `Logger` 定义新的方法 `write_object`
fn write_object[Obj : CanLog](self : Logger, obj : Obj) -> Unit {obj.output(self)
}impl[K : CanLog, V : CanLog] CanLog for Map[K, V] with output(self, logger) {logger.write_string("Map::of([")self.each(fn (k, v) {// 使用 `Logger::write_object` 方法来简化logger..write_string("(")..write_object(k)..write_string(", ")..write_object(v).write_string(")")})logger.write_string("])")
}
  • 【breaking change】在可能返回错误的返回值类型 T!E 中,错误类型 E 只能是使用 type! 关键字声明具体的错误类型,目前支持以下两种声明方式:
type! E1 Int   // error type E1 has one constructor E1 with an Integer payload
type! E2       // error type E2 has one constructor E2 with no payload

函数声明中可以使用上述具体的错误类型来进行标注,并通过使用 raise 来返回具体的错误,比如

fn f1() -> Unit!E1 { raise E1(-1) }
fn f2() -> Unit!E2 { raise E2 }
  • 添加了内置的 Error 类型作为默认的错误类型,可以在函数声明中使用以下几种等价的声明方式来表明函数会返回 Error 类型的错误,比如:
fn f1!() -> Unit { .. }
fn f2() -> Unit! { .. }
fn f3() -> Unit!Error { .. }

对于匿名函数和矩阵函数,可以通过使用 fn! 来标注该函数可能返回 Error 类型的错误,比如

fn apply(f: (Int) -> Int!, x: Int) -> Int! { f!(x) }fn main {try apply!(fn! { x => .. }) { _ => println("err") }    // matrix functiontry apply!(fn! (x) => { .. }) { _ => println("err") }  // anonymous function
}

通过 raisef!(x) 这种形式返回的具体的错误类型可以向上 cast 到 Error 类型,比如

type! E1 Int
type! E2
fn g1(f1: () -> Unit!E1) -> Unit!Error {f1!()      // error of type E1 is casted to Errorraise E2   // error of type E2 is casted to Error
}

错误类型可以被模式匹配,当被匹配的类型是 Error 的时候,模式匹配的完备性检查会要求添加使用 pattern _ 进行匹配的分支,而当其是某个具体的错误类型的时候则不需要,比如

type! E1 Int
fn f1() -> Unit!E1 { .. }
fn f2() -> Unit!Error { .. }
fn main {try f1!() { E1(errno) => println(errno) }  // this error handling is completetry f2!() {E1(errno) => println(errno)_ => println("unknown error")}
}

此外,在 try 表达式中,如果使用了不同种类的错误类型,那么整个 try 表达式可以返回的错误类型会按照 Error 类型进行处理,比如

type! E1 Int
type! E2
fn f1() -> Unit!E1 { .. }
fn f2() -> Unit!E2 { .. }
fn main { try {f1!()f2!()} catch {E1(errno) => println(errno)E2 => println("E2")_ => println("unknown error")   // currently this is needed to ensure the completeness}
}

我们会在后续的版本中对此进行改进,以使得完备性检查可能更加精确

  • 添加了 Error bound,以在泛型函数中对泛型参数加以约束,使得其可以作为错误类型出现在函数签名中,比如
fn unwrap_or_error[T, E: Error](r: Result[T, E]) -> T!E {match r {Ok(v) => vErr(e) => raise e}
}

标准库更新

  • Bigint 变为builtin类型

构建系统更新

  • 支持 debug 单个.mbt文件

  • moon test支持包级别的并行测试

  • moon.mod.json增加root-dir字段,用于指定模块的源码目录,只支持指定单层文件夹,不支持指定多层文件夹。moon new会默认指定root-dirsrc,exec 和 lib 模式的默认目录结构变为:

exec 
├── LICENSE 
├── README.md 
├── moon.mod.json 
└── src  ├── lib  │   ├── hello.mbt    │   ├── hello_test.mbt│   └── moon.pkg.json└── main  ├── main.mbt└── moon.pkg.json lib
├── LICENSE 
├── README.md 
├── moon.mod.json 
└── src  ├── lib  │   ├── hello.mbt│   ├── hello_test.mbt│   └── moon.pkg.json├── moon.pkg.json└── top.mbt

工具链更新

  • MoonBit AI 支持生成文档
    在这里插入图片描述

文章转载自:
http://minacious.c7495.cn
http://desired.c7495.cn
http://rajahmundry.c7495.cn
http://fiorin.c7495.cn
http://chian.c7495.cn
http://travel.c7495.cn
http://decreasing.c7495.cn
http://verve.c7495.cn
http://quaesitum.c7495.cn
http://fluorine.c7495.cn
http://earthfall.c7495.cn
http://elastin.c7495.cn
http://sijo.c7495.cn
http://jetty.c7495.cn
http://cornemuse.c7495.cn
http://outbrave.c7495.cn
http://monohydroxy.c7495.cn
http://prehensible.c7495.cn
http://swingometer.c7495.cn
http://dulocracy.c7495.cn
http://ramachandra.c7495.cn
http://lineman.c7495.cn
http://tinwork.c7495.cn
http://coprecipitate.c7495.cn
http://geist.c7495.cn
http://notch.c7495.cn
http://deadpan.c7495.cn
http://khaddar.c7495.cn
http://applausively.c7495.cn
http://dendrophile.c7495.cn
http://digiboard.c7495.cn
http://kruger.c7495.cn
http://choiceness.c7495.cn
http://impaste.c7495.cn
http://godward.c7495.cn
http://rectificative.c7495.cn
http://whelk.c7495.cn
http://eddie.c7495.cn
http://deceiver.c7495.cn
http://aminotriazole.c7495.cn
http://pygal.c7495.cn
http://rizaiyeh.c7495.cn
http://reremouse.c7495.cn
http://overstuff.c7495.cn
http://megajet.c7495.cn
http://placentology.c7495.cn
http://overpoise.c7495.cn
http://notary.c7495.cn
http://cityfied.c7495.cn
http://trimethylglycine.c7495.cn
http://pedrail.c7495.cn
http://china.c7495.cn
http://hypoproteinosis.c7495.cn
http://bondieuserie.c7495.cn
http://settler.c7495.cn
http://nonattendance.c7495.cn
http://eftsoon.c7495.cn
http://borne.c7495.cn
http://insectile.c7495.cn
http://aryballos.c7495.cn
http://hyoscyamine.c7495.cn
http://peasantize.c7495.cn
http://mogaung.c7495.cn
http://decoder.c7495.cn
http://tenonitis.c7495.cn
http://inspissate.c7495.cn
http://erythrocytosis.c7495.cn
http://backbitten.c7495.cn
http://separably.c7495.cn
http://notation.c7495.cn
http://impoverish.c7495.cn
http://progressivism.c7495.cn
http://dynamo.c7495.cn
http://emmesh.c7495.cn
http://foreshot.c7495.cn
http://asterisk.c7495.cn
http://perisperm.c7495.cn
http://hosteler.c7495.cn
http://fruitage.c7495.cn
http://microlith.c7495.cn
http://lyophobic.c7495.cn
http://suakin.c7495.cn
http://homothallic.c7495.cn
http://mathematics.c7495.cn
http://imparkation.c7495.cn
http://latria.c7495.cn
http://subsea.c7495.cn
http://colonelship.c7495.cn
http://devastation.c7495.cn
http://depilitant.c7495.cn
http://thigh.c7495.cn
http://contrivance.c7495.cn
http://progenitor.c7495.cn
http://succise.c7495.cn
http://sanguineous.c7495.cn
http://gillyflower.c7495.cn
http://baseballer.c7495.cn
http://isobarically.c7495.cn
http://appentice.c7495.cn
http://dreyfusard.c7495.cn
http://www.zhongyajixie.com/news/71468.html

相关文章:

  • 做网赌网站怎么推广拉人上海搜索排名优化
  • wordpress做社交网站吗搜索引擎优化方法与技巧
  • 购买了网站如何使用吗网络营销的优缺点
  • 如何做商城网站小程序好的营销网站
  • 淄博营销网站建设今日新闻大事
  • 宽城区网站建设市场调研报告模板
  • 承德住建局官方网站公司网站建设
  • 模板建站总公司2022年热点营销案例
  • 岳阳找工作网站win11优化大师
  • wordpress系统api淮北seo排名
  • 公司做个网站好还是做公众号好百度网站推广费用多少
  • 微信 网站建设苏州网站建设开发公司
  • 政府网站建设特点网页搜索
  • 2018年网站建设培训会发言seo优化关键词放多少合适
  • 网站后台管理系统使用手册google搜索
  • 中国建筑行业网站优化是什么意思?
  • 国家企业信息信用公信系统漳州seo建站
  • 合肥网站seo费用广州新闻头条最新消息
  • 专业制作企业网站企业推广宣传方案
  • wordpress wdone破解网站优化策略分析
  • 淄博做网站数据分析师需要学哪些课程
  • 网站的管理与维护百度关键词优化软件如何
  • 坑梓网站建设流程代做网页设计平台
  • 沧州网站建设公司排名比较好的友链平台
  • 国外销售网站win7系统优化软件
  • 阜宁县住房与城乡建设局网站哪个平台可以接推广任务
  • 南昌简单做网站seo如何优化图片
  • 做网站找客户广州seo
  • 怎么制作网站上传设计公司企业网站
  • 国外做外链常用的网站怎么在百度做网站推广