hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
276 stars 22 forks source link

Zig: Pro #377

Open hhstore opened 1 year ago

hhstore commented 1 year ago

related:

hhstore commented 1 year ago

Zig 进阶:

官方文档:

zig 语法关键字:

zig 语法练习:

hhstore commented 1 year ago

Zig 核心语法点:

💢 1. 数据类型:

基础数据类型:

Optionals: (类似 Rust Option)

null:

undefined:

Arrays: 数组

Vectors: 容器

Slices: 切片

struct: 结构体

extern-struct:

Pointers: 指针

💢 2. 基本语法:

opaque: ⭐⭐⭐⭐⭐

blocks: 块语法, 类似 rust/go, {}, 生命周期概念.

noreturn:

💢 3. 进阶语法:

3.1 错误处理:

defer / errdefer:

try / catch: 异常机制

switch: 类似 rust match

unreachable:

3.2 comptime: 类似泛型

3.3 编译期反射和编译期代码执行:

3.4 异步(Async/Await):

3.5 C 语言互操作:

hhstore commented 1 year ago

Zig 语法进阶:

type vs anytype:

anytype 用例:

comptime:

典型例子:

errors:

文档:

示例:

Builtin-Functions 内建方法集:

hhstore commented 1 year ago

1

hhstore commented 1 year ago

1