This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iterator sillyOne(x, y:int): int {.closure.} = | |
var z = x | |
while z < y: | |
yield z | |
inc(z) | |
when defined(isMainModule): | |
var x = sillyOne | |
echo(x(1, 20)) | |
echo(x(1, 21)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iterator sillyOne(y:string): int {.closure.} = | |
var x = "" | |
while true: | |
x = x & y | |
yield x | |
when defined(isMainModule): | |
var x = sillyOne | |
echo(x("Hello")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-- 1 | |
Traceback (most recent call last) | |
nimrod.nim(79) nimrod | |
nimrod.nim(55) HandleCmdLine | |
main.nim(308) MainCommand | |
main.nim(73) CommandCompileToC | |
modules.nim(193) CompileProject | |
modules.nim(151) compileModule | |
passes.nim(192) processModule | |
passes.nim(136) processTopLevelStmt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import queues | |
when defined(isMainModule): | |
var x = initQueue[float](4) | |
add[float](x, 20) # Must be specified, else the compiler doesn't know if 20 is an int or a float | |
echo(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test.nim(38, 8) Info: instantiation from here | |
test.nim(28, 11) Info: instantiation from here | |
test.nim(38, 8) Info: instantiation from here | |
test.nim(28, 11) Info: instantiation from here | |
lib\pure\marshal.nim(242, 9) Error: internal error: instantiateGenericParamList: T | |
Traceback (most recent call last) | |
nimrod.nim(79) nimrod | |
nimrod.nim(55) HandleCmdLine | |
main.nim(308) MainCommand | |
main.nim(73) CommandCompileToC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
of nkBracketExpr: # Line 1923 of semexpr.nim | |
checkMinSonsLen(n, 1) | |
var s = qualifiedLookup(c, n.sons[0], {checkUndeclared}) | |
if not isNil(n.sons[0]) and n.sons[0].kind in {nkDotExpr}: | |
var dotSon = n.sons[0] | |
if not isNil(dotSon): | |
var lastSon = dotSon.sons[dotSon.sons.len-1] | |
if not isNil(lastSon) and lastSon.kind in {nkIdent}: | |
var g = qualifiedLookup(c, lastSon, {checkUndeclared}) # Errors in system.nim, line 2203 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test.nim(41, 8) Info: instantiation from here | |
test.nim(29, 13) Info: instantiation from here | |
test.nim(41, 8) Info: instantiation from here | |
test.nim(29, 13) Info: instantiation from here | |
lib\pure\marshal.nim(242, 9) Error: internal error: instantiateGenericParamList: T | |
Traceback (most recent call last) | |
nimrod.nim(79) nimrod | |
nimrod.nim(55) HandleCmdLine | |
main.nim(308) MainCommand | |
main.nim(73) CommandCompileToC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Imports | |
import marshal | |
import macros | |
## Types | |
type TLog* = ref object | |
path: string | |
file: TFile | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This works | |
iterator testGenProc[iT, rT](iter:iT): rT {.closure.} = | |
for i in iter: | |
yield i | |
var x = testGenProc[seq[int],int] | |
echo(x(@[1,2,3])) | |
echo(x(@[1,2,3])) | |
# This doesn't |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iterator cycle* [iterType, returnType](iter:iterType): returnType = | |
## An iterator returning elements from the iterable and saving a | |
## copy of each. When the iterable is exhausted, return elements | |
## from the saved copy. Repeats indefinitely. | |
## | |
## Parameters: | |
## iter: The iterator to cycle through | |
var cont:seq[returnType] | |
cont = newSeq[returnType]() | |
for element in iter: |