Nim - the first high performance language with full support for hot codereloading at runtimeconcepts discriminated unions strong typedefs (distinct type) - can has $ currency? coroutines & closures switch & pattern matching dynamic dispatch & multi-methods converters - explicit (for implicit conversions) newData(); // << call //... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 28 Nim closures to C/C++ (resumable funcs) Nim closures to C/C++ (resumable funcs) iterator closure_iter*(): int {.closure.} = # a0 码力 | 63 页 | 2.91 MB | 1 年前3
Nim 2.0.8 Manualarguments still need () to distinguish between a call and the function itself as a �rst-class value. Closures Procedures can appear at the top level in a module as well as inside other scopes, in which case optarg optarg 8 # same thing as above, w/o the parenthesis assert x == y Creating closures in loops Since closures capture local variables by reference it is often not wanted behavior inside loop bodies0 码力 | 132 页 | 5.73 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 512 页 | 3.54 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 508 页 | 3.50 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 512 页 | 3.53 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 508 页 | 3.54 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 508 页 | 3.50 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 508 页 | 3.52 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 508 页 | 3.53 MB | 1 年前3
Computer Programming with the Nim Programming Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Nested procedures and closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . values 1 and -1 in the cmp() procedure above, you would invert the sort order. Nested procedures and closures While in C, all functions must be defined in the top-level scope and nesting of functions is not feature of the Nim language and offers two things: [3] • A different way to pass anonymous procs/closures to a procedure • A way to pass two code blocks to a template. We will not try to explain the magic0 码力 | 512 页 | 3.50 MB | 1 年前3
共 30 条
- 1
- 2
- 3













