Nim 2.0.2 中文手册⼩的数组通常很有⽤。另 外,未检查数组可以转换为不确定⼤⼩的 C 数组: ⽣成的 C 代码⼤致是这样的: 未检查数组的基本类型可能不包含任何 GC内存,但⽬前尚未检查。 未来⽅向: 应该在未检查的数组中允许 GC内存,并且应该有⼀个关于 GC 如何确定数组的运⾏时⼤⼩的显式注解。 元组和对象类型 元组或对象类型的变量是异构存储容器。元组或对象定义了⼀个类型的各类 字段 。元组还定义了字段的 = nil: # 如果 p 是 nil , 那么 `p[]` 会导致错误 # 所以这⾥的 `p` 永远不会是 nil action() p[].field = 3 action() 混合GC内存和 ptr 要特别注意的是,如果⼀个未被追踪的对象包含被追踪的对象,例如包含追踪的引⽤、字符串、序列。为了正确释放所有对象, 在释放未被追踪的内存之前,需要⼿动调⽤内置过程 reset : string] # 在堆上为 Data 分配内存: var d = cast[ptr Data](alloc0(sizeof(Data))) # 在垃圾回收(GC)堆上创建⼀个新的字符串: d.s = "abc" # 告知 GC 不再需要这个字符串: reset(d.s) # 释放内存: dealloc(d) proc printItem(x: int) = ... proc forEach(c:0 码力 | 127 页 | 7.05 MB | 1 年前3
Nim 2.0.8 Manualcontain any GC'ed memory but this is currently not checked. Future directions: GC'ed memory should be allowed in unchecked arrays and there should be an explicit annotation of how the GC is to determine Into: Note: This is not comparable to C's "unde�ned behavior" for dereferencing NULL pointers. Mixing GC'ed memory with ptr Special care has to be taken if an untraced object contains traced objects like Data](alloc0(sizeof(Data))) # create a new string on the garbage collected heap: d.s = "abc" # tell the GC that the string is not needed anymore: reset(d.s) # free the memory: dealloc(d) proc printItem(x:0 码力 | 132 页 | 5.73 MB | 1 年前3
Computer Programming with the Nim Programming Language
production. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays object- oriented Static, weak Braces, semicolons Native Destructors, RAII, manual, optional GC Yes, Templates Text preprocessor C++20 Nim Imperative, procedural, structured, functional Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScript) GC, refcount, destructors Yes AST based, hygienic Yes Rust Imperative, procedural, structured,0 码力 | 865 页 | 7.45 MB | 1 年前3
Computer Programming with the Nim Programming Language
production. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays object- oriented Static, weak Braces, semicolons Native Destructors, RAII, manual, optional GC Yes, Templates Text preprocessor C++20 Nim Imperative, procedural, structured, functional Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScript) GC, refcount, destructors Yes AST based, hygienic Yes Rust Imperative, procedural, structured,0 码力 | 784 页 | 2.13 MB | 1 年前3
Computer Programming with the Nim Programming Languageproduction. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays oriented Static, weak Braces, semi colons Native Destruc tors, RAII, manual, optional GC Yes, Tem plates Text pre processor C++20 Nim Impera tive, pro cedural, struc tured, Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScri pt) GC, ref count, destruc tors Yes AST based, hygienic Yes 25 Lan guage Para digm Typing0 码力 | 512 页 | 3.54 MB | 1 年前3
Computer Programming with the Nim Programming Languageproduction. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays object-ori ented Static, weak Braces, semi colons Native Destruc tors, RAII, manual, optional GC Yes, Tem plates Text pre processor C++20 Nim Impera tive, pro cedural, struc tured, Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScrip t) GC, ref count, destruc tors Yes AST based, hygienic Yes Rust Impera tive, pro cedural,0 码力 | 508 页 | 3.50 MB | 1 年前3
Computer Programming with the Nim Programming Languageproduction. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays oriented Static, weak Braces, semi colons Native Destruc tors, RAII, manual, optional GC Yes, Tem plates Text pre processor C++20 Nim Impera tive, pro cedural, struc tured, Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScri pt) GC, ref count, destruc tors Yes AST based, hygienic Yes 25 Lan guage Para digm Typing0 码力 | 512 页 | 3.53 MB | 1 年前3
Computer Programming with the Nim Programming Languageproduction. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays object-ori ented Static, weak Braces, semi colons Native Destruc tors, RAII, manual, optional GC Yes, Tem plates Text pre processor C++20 Nim Impera tive, pro cedural, struc tured, Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScrip t) GC, ref count, destruc tors Yes AST based, hygienic Yes Rust Impera tive, pro cedural,0 码力 | 508 页 | 3.54 MB | 1 年前3
Computer Programming with the Nim Programming Languageproduction. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays object-ori ented Static, weak Braces, semi colons Native Destruc tors, RAII, manual, optional GC Yes, Tem plates Text pre processor C++20 Nim Impera tive, pro cedural, struc tured, Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScrip t) GC, ref count, destruc tors Yes AST based, hygienic Yes Rust Impera tive, pro cedural,0 码力 | 508 页 | 3.50 MB | 1 年前3
Computer Programming with the Nim Programming Languageproduction. ORC gives us GC-like, fully deterministic memory management with minimal overhead compared to manual memory handling. It reduces the maximal memory consumption of apps, avoids GC-generated delays object-ori ented Static, weak Braces, semi colons Native Destruc tors, RAII, manual, optional GC Yes, Tem plates Text pre processor C++20 Nim Impera tive, pro cedural, struc tured, Static, strong, inferred Python- like (off- side rule) Native, web browser (JavaScrip t) GC, ref count, destruc tors Yes AST based, hygienic Yes Rust Impera tive, pro cedural,0 码力 | 508 页 | 3.52 MB | 1 年前3
共 32 条
- 1
- 2
- 3
- 4













