Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove default argument for readLines #12807

Merged
merged 7 commits into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/vmops.nim
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ proc registerAdditionalOps*(c: PCtx) =
wrap1s(fileExists, osop)
wrapDangerous(writeFile, ioop)
wrap1s(readFile, ioop)
wrap2si(readLines, ioop)
wrap2si(staticReadLines, ioop)
systemop getCurrentExceptionMsg
systemop getCurrentException
registerCallback c, "stdlib.*.staticWalkDir", proc (a: VmArgs) {.nimcall.} =
Expand Down
6 changes: 3 additions & 3 deletions lib/system/io.nim
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,10 @@ proc writeFile*(filename: string, content: openArray[byte]) {.since: (1, 1).} =
else:
raise newException(IOError, "cannot open: " & filename)

proc readLines*(filename: string, n = 1.Natural): seq[TaintedString] =
## read `n` lines from the file named `filename`. Raises an IO exception
proc staticReadLines*(filename: string, n: Natural): seq[TaintedString] =
## Compile time read `n` lines from the file named `filename`. Raises an IO exception
## in case of an error. Raises EOF if file does not contain at least `n` lines.
## Available at compile time. A line of text may be delimited by ``LF`` or ``CRLF``.
## A line of text may be delimited by ``LF`` or ``CRLF``.
## The newline character(s) are not part of the returned strings.
var f: File
if open(f, filename):
Expand Down
2 changes: 1 addition & 1 deletion tests/vm/tfile_rw.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static:
writeFile(filename, mytext)
const myfile_str = staticRead(filename)
const myfile_str2 = readFile(filename)
const myfile_str_seq = readLines(filename, 3)
const myfile_str_seq = staticReadLines(filename, 3)

static:
doAssert myfile_str == mytext
Expand Down