Open andrewgohlk opened 1 year ago
The below sequence code on Page 42 is not able to compile in nim 2.0:
let list = @[4, 8, 15, 16, 23, 42] for i in 0 .. <list.len: stdout.write($list[i] & " ")
Encountered the following error: D:\nimTest\seqTest.nim(2, 15) Error: type mismatch Expression: <=len(list) [1] len(list): int
Expected one of (first mismatch at [position]): [1] proc <=(x, y: bool): bool [1] proc <=(x, y: char): bool [1] proc <=(x, y: float): bool [1] proc <=(x, y: float32): bool [1] proc <=(x, y: int16): bool [1] proc <=(x, y: int32): bool [1] proc <=(x, y: int8): bool [1] proc <=(x, y: pointer): bool [1] proc <=(x, y: string): bool [1] proc <=(x, y: uint): bool [1] proc <=(x, y: uint16): bool [1] proc <=(x, y: uint32): bool [1] proc <=(x, y: uint64): bool [1] proc <=(x, y: uint8): bool [1] proc <=[Enum: enum](x, y: Enum): bool [1] proc <=[T: tuple](x, y: T): bool [1] proc <=[T](x, y: ref T): bool [1] proc <=[T](x, y: set[T]): bool [2] proc <=(x, y: int): bool [2] proc <=(x, y: int64): bool
<=
========================
However, removing the space after the '..' fix the issue.
let list = @[4, 8, 15, 16, 23, 42] for i in 0 ..< list.len: stdout.write($list[i] & " ")
Before nim 1.4.0 (not sure of the exact version), the operator was .. and < was a template symbol for the substraction by 1. This is true for all listings in Nim in Action and most of ancient Nim code.
..
<
The below sequence code on Page 42 is not able to compile in nim 2.0:
let list = @[4, 8, 15, 16, 23, 42] for i in 0 .. <list.len: stdout.write($list[i] & " ")
Encountered the following error: D:\nimTest\seqTest.nim(2, 15) Error: type mismatch Expression: <=len(list) [1] len(list): int
Expected one of (first mismatch at [position]): [1] proc
<=
(x, y: bool): bool [1] proc<=
(x, y: char): bool [1] proc<=
(x, y: float): bool [1] proc<=
(x, y: float32): bool [1] proc<=
(x, y: int16): bool [1] proc<=
(x, y: int32): bool [1] proc<=
(x, y: int8): bool [1] proc<=
(x, y: pointer): bool [1] proc<=
(x, y: string): bool [1] proc<=
(x, y: uint): bool [1] proc<=
(x, y: uint16): bool [1] proc<=
(x, y: uint32): bool [1] proc<=
(x, y: uint64): bool [1] proc<=
(x, y: uint8): bool [1] proc<=
[Enum: enum](x, y: Enum): bool [1] proc<=
[T: tuple](x, y: T): bool [1] proc<=
[T](x, y: ref T): bool [1] proc<=
[T](x, y: set[T]): bool [2] proc<=
(x, y: int): bool [2] proc<=
(x, y: int64): bool========================
However, removing the space after the '..' fix the issue.
let list = @[4, 8, 15, 16, 23, 42] for i in 0 ..< list.len: stdout.write($list[i] & " ")