Merge pull request #2961 from Perelandric/rename_writeLn

Renamed writeln to writeLine. Issue #2958
This commit is contained in:
Dominik Picheta 2015-06-20 16:25:37 +01:00
commit e74012b396
71 changed files with 815 additions and 801 deletions

View file

@ -452,7 +452,7 @@ proc debug(n: PSym) =
elif n.kind == skUnknown:
msgWriteln("skUnknown")
else:
#writeln(stdout, $symToYaml(n, 0, 1))
#writeLine(stdout, $symToYaml(n, 0, 1))
msgWriteln("$1_$2: $3, $4, $5, $6" % [
n.name.s, $n.id, $flagsToStr(n.flags), $flagsToStr(n.loc.flags),
$lineInfoToStr(n.info), $n.kind])

View file

@ -596,7 +596,7 @@ proc externalFileChanged(filename: string): bool =
result = true
if result:
if open(f, crcFile, fmWrite):
f.writeln($currentCrc)
f.writeLine($currentCrc)
close(f)
proc addExternalFileToCompile*(filename: string) =

View file

@ -48,8 +48,8 @@ proc toGid(f: string): string =
proc saveMaxIds*(project: string) =
var f = open(project.toGid, fmWrite)
f.writeln($gFrontEndId)
f.writeln($gBackendId)
f.writeLine($gFrontEndId)
f.writeLine($gBackendId)
f.close()
proc loadMaxIds*(project: string) =

View file

@ -593,7 +593,7 @@ var
proc suggestWriteln*(s: string) =
if eStdOut in errorOutputs:
if isNil(writelnHook): writeln(stdout, s)
if isNil(writelnHook): writeLine(stdout, s)
else: writelnHook(s)
proc msgQuit*(x: int8) = quit x
@ -688,7 +688,7 @@ var gTrackPos*: TLineInfo
proc outWriteln*(s: string) =
## Writes to stdout. Always.
if eStdOut in errorOutputs: writeln(stdout, s)
if eStdOut in errorOutputs: writeLine(stdout, s)
proc msgWriteln*(s: string) =
## Writes to stdout. If --stdout option is given, writes to stderr instead.
@ -698,9 +698,9 @@ proc msgWriteln*(s: string) =
if not isNil(writelnHook):
writelnHook(s)
elif optStdout in gGlobalOptions:
if eStdErr in errorOutputs: writeln(stderr, s)
if eStdErr in errorOutputs: writeLine(stderr, s)
else:
if eStdOut in errorOutputs: writeln(stdout, s)
if eStdOut in errorOutputs: writeLine(stdout, s)
macro callIgnoringStyle(theProc: typed, first: typed,
args: varargs[expr]): stmt =
@ -735,13 +735,13 @@ template styledMsgWriteln*(args: varargs[expr]) =
if not isNil(writelnHook):
callIgnoringStyle(callWritelnHook, nil, args)
elif optStdout in gGlobalOptions:
if eStdErr in errorOutputs: callIgnoringStyle(writeln, stderr, args)
if eStdErr in errorOutputs: callIgnoringStyle(writeLine, stderr, args)
else:
if eStdOut in errorOutputs:
if optUseColors in gGlobalOptions:
callStyledEcho(args)
else:
callIgnoringStyle(writeln, stdout, args)
callIgnoringStyle(writeLine, stdout, args)
proc coordToStr(coord: int): string =
if coord == -1: result = "???"

View file

@ -82,7 +82,7 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
proc handleCmdLine() =
if paramCount() == 0:
stdout.writeln(Usage)
stdout.writeLine(Usage)
else:
processCmdLine(passCmd1, "")
if gProjectName != "":

View file

@ -304,7 +304,7 @@ proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string =
when noTimeMachine:
excludeDirFromTimeMachine(subdir)
except OSError:
writeln(stdout, "cannot create directory: " & subdir)
writeLine(stdout, "cannot create directory: " & subdir)
quit(1)
result = joinPath(subdir, tail)
#echo "completeGeneratedFilePath(", f, ") = ", result

View file

@ -1031,28 +1031,28 @@ proc viewFile(rodfile: string) =
case section
of "CRC":
inc(r.pos) # skip ':'
outf.writeln("CRC:", $decodeVInt(r.s, r.pos))
outf.writeLine("CRC:", $decodeVInt(r.s, r.pos))
of "ID":
inc(r.pos) # skip ':'
r.moduleID = decodeVInt(r.s, r.pos)
setId(r.moduleID)
outf.writeln("ID:", $r.moduleID)
outf.writeLine("ID:", $r.moduleID)
of "ORIGFILE":
inc(r.pos)
r.origFile = decodeStr(r.s, r.pos)
outf.writeln("ORIGFILE:", r.origFile)
outf.writeLine("ORIGFILE:", r.origFile)
of "OPTIONS":
inc(r.pos) # skip ':'
r.options = cast[TOptions](int32(decodeVInt(r.s, r.pos)))
outf.writeln("OPTIONS:", $r.options)
outf.writeLine("OPTIONS:", $r.options)
of "GOPTIONS":
inc(r.pos) # skip ':'
let dep = cast[TGlobalOptions](int32(decodeVInt(r.s, r.pos)))
outf.writeln("GOPTIONS:", $dep)
outf.writeLine("GOPTIONS:", $dep)
of "CMD":
inc(r.pos) # skip ':'
let dep = cast[TCommands](int32(decodeVInt(r.s, r.pos)))
outf.writeln("CMD:", $dep)
outf.writeLine("CMD:", $dep)
of "DEFINES":
inc(r.pos) # skip ':'
var d = 0
@ -1074,7 +1074,7 @@ proc viewFile(rodfile: string) =
r.files.add(finalPath.fileInfoIdx)
inc(r.pos) # skip #10
inc(r.line)
outf.writeln finalPath
outf.writeLine finalPath
if r.s[r.pos] == ')': inc(r.pos)
outf.write(")\n")
of "INCLUDES":

View file

@ -218,12 +218,12 @@ proc cmpCandidates*(a, b: TCandidate): int =
result = complexDisambiguation(a.callee, b.callee)
proc writeMatches*(c: TCandidate) =
writeln(stdout, "exact matches: " & $c.exactMatches)
writeln(stdout, "generic matches: " & $c.genericMatches)
writeln(stdout, "subtype matches: " & $c.subtypeMatches)
writeln(stdout, "intconv matches: " & $c.intConvMatches)
writeln(stdout, "conv matches: " & $c.convMatches)
writeln(stdout, "inheritance: " & $c.inheritancePenalty)
writeLine(stdout, "exact matches: " & $c.exactMatches)
writeLine(stdout, "generic matches: " & $c.genericMatches)
writeLine(stdout, "subtype matches: " & $c.subtypeMatches)
writeLine(stdout, "intconv matches: " & $c.intConvMatches)
writeLine(stdout, "conv matches: " & $c.convMatches)
writeLine(stdout, "inheritance: " & $c.inheritancePenalty)
proc argTypeToString(arg: PNode; prefer: TPreferedDesc): string =
if arg.kind in nkSymChoices:

View file

@ -222,13 +222,13 @@ Call with named arguments
Concrete syntax:
.. code-block:: nim
writeln(file=stdout, "hallo")
writeLine(file=stdout, "hallo")
AST:
.. code-block:: nim
nnkCall(
nnkIdent(!"writeln"),
nnkIdent(!"writeLine"),
nnkExprEqExpr(
nnkIdent(!"file"),
nnkIdent(!"stdout")

View file

@ -53,7 +53,7 @@ The following example shows a generic binary tree can be modelled:
add(root, newNode("hallo")) # instantiates generic procs ``newNode`` and
add(root, newNode("world")) # ``add``
for str in inorder(root):
writeln(stdout, str)
writeLine(stdout, str)
Is operator

View file

@ -132,7 +132,7 @@ to supply any type of first argument for procedures:
echo("abc".len) # is the same as echo(len("abc"))
echo("abc".toUpper())
echo({'a', 'b', 'c'}.card)
stdout.writeln("Hallo") # the same as writeln(stdout, "Hallo")
stdout.writeLine("Hallo") # the same as writeLine(stdout, "Hallo")
Another way to look at the method call syntax is that it provides the missing
postfix notation.

View file

@ -77,10 +77,10 @@ special ``:`` syntax:
quit("cannot open: " & fn)
withFile(txt, "ttempl3.txt", fmWrite):
txt.writeln("line 1")
txt.writeln("line 2")
txt.writeLine("line 1")
txt.writeLine("line 2")
In the example the two ``writeln`` statements are bound to the ``actions``
In the example the two ``writeLine`` statements are bound to the ``actions``
parameter.
@ -206,8 +206,8 @@ template parameter, it is an inject'ed symbol:
...
withFile(txt, "ttempl3.txt", fmWrite):
txt.writeln("line 1")
txt.writeln("line 2")
txt.writeLine("line 1")
txt.writeLine("line 2")
The ``inject`` and ``gensym`` pragmas are second class annotations; they have
@ -299,7 +299,7 @@ variable number of arguments:
# add a call to the statement list that writes ": "
add(result, newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
# add a call to the statement list that writes the expressions value:
add(result, newCall("writeln", newIdentNode("stdout"), n[i]))
add(result, newCall("writeLine", newIdentNode("stdout"), n[i]))
var
a: array [0..10, int]
@ -314,15 +314,15 @@ The macro call expands to:
.. code-block:: nim
write(stdout, "a[0]")
write(stdout, ": ")
writeln(stdout, a[0])
writeLine(stdout, a[0])
write(stdout, "a[1]")
write(stdout, ": ")
writeln(stdout, a[1])
writeLine(stdout, a[1])
write(stdout, "x")
write(stdout, ": ")
writeln(stdout, x)
writeLine(stdout, x)
Arguments that are passed to a ``varargs`` parameter are wrapped in an array
@ -333,7 +333,7 @@ children.
BindSym
-------
The above ``debug`` macro relies on the fact that ``write``, ``writeln`` and
The above ``debug`` macro relies on the fact that ``write``, ``writeLine`` and
``stdout`` are declared in the system module and thus visible in the
instantiating context. There is a way to use bound identifiers
(aka `symbols`:idx:) instead of using unbound identifiers. The ``bindSym``
@ -348,7 +348,7 @@ builtin can be used for that:
# we can bind symbols in scope via 'bindSym':
add(result, newCall(bindSym"write", bindSym"stdout", toStrLit(n[i])))
add(result, newCall(bindSym"write", bindSym"stdout", newStrLitNode(": ")))
add(result, newCall(bindSym"writeln", bindSym"stdout", n[i]))
add(result, newCall(bindSym"writeLine", bindSym"stdout", n[i]))
var
a: array [0..10, int]
@ -363,17 +363,17 @@ The macro call expands to:
.. code-block:: nim
write(stdout, "a[0]")
write(stdout, ": ")
writeln(stdout, a[0])
writeLine(stdout, a[0])
write(stdout, "a[1]")
write(stdout, ": ")
writeln(stdout, a[1])
writeLine(stdout, a[1])
write(stdout, "x")
write(stdout, ": ")
writeln(stdout, x)
writeLine(stdout, x)
However, the symbols ``write``, ``writeln`` and ``stdout`` are already bound
However, the symbols ``write``, ``writeLine`` and ``stdout`` are already bound
and are not looked up again. As the example shows, ``bindSym`` does work with
overloaded symbols implicitly.

View file

@ -272,7 +272,7 @@ parameter is of the type ``varargs`` it is treated specially and it can match
.. code-block:: nim
template optWrite{
write(f, x)
((write|writeln){w})(f, y)
((write|writeLine){w})(f, y)
}(x, y: varargs[expr], f: File, w: expr) =
w(f, x, y)

View file

@ -207,7 +207,7 @@ for any type:
echo("abc".len) # is the same as echo(len("abc"))
echo("abc".toUpper())
echo({'a', 'b', 'c'}.card)
stdout.writeln("Hallo") # the same as writeln(stdout, "Hallo")
stdout.writeLine("Hallo") # the same as writeLine(stdout, "Hallo")
(Another way to look at the method call syntax is that it provides the missing
postfix notation.)
@ -217,9 +217,9 @@ So "pure object oriented" code is easy to write:
.. code-block:: nim
import strutils
stdout.writeln("Give a list of numbers (separated by spaces): ")
stdout.writeLine("Give a list of numbers (separated by spaces): ")
stdout.write(stdin.readLine.split.map(parseInt).max.`$`)
stdout.writeln(" is the maximum!")
stdout.writeLine(" is the maximum!")
Properties
@ -535,7 +535,7 @@ containers:
add(root, newNode("hello")) # instantiates ``newNode`` and ``add``
add(root, "world") # instantiates the second ``add`` proc
for str in preorder(root):
stdout.writeln(str)
stdout.writeLine(str)
The example shows a generic binary tree. Depending on context, the brackets are
used either to introduce type parameters or to instantiate a generic proc,
@ -580,7 +580,7 @@ simple proc for logging:
debug = true
proc log(msg: string) {.inline.} =
if debug: stdout.writeln(msg)
if debug: stdout.writeLine(msg)
var
x = 4
@ -597,7 +597,7 @@ Turning the ``log`` proc into a template solves this problem:
debug = true
template log(msg: string) =
if debug: stdout.writeln(msg)
if debug: stdout.writeLine(msg)
var
x = 4
@ -627,10 +627,10 @@ via a special ``:`` syntax:
quit("cannot open: " & fn)
withFile(txt, "ttempl3.txt", fmWrite):
txt.writeln("line 1")
txt.writeln("line 2")
txt.writeLine("line 1")
txt.writeLine("line 2")
In the example the two ``writeln`` statements are bound to the ``body``
In the example the two ``writeLine`` statements are bound to the ``body``
parameter. The ``withFile`` template contains boilerplate code and helps to
avoid a common bug: to forget to close the file. Note how the
``let fn = filename`` statement ensures that ``filename`` is evaluated only
@ -684,7 +684,7 @@ variable number of arguments:
# add a call to the statement list that writes ": "
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
# add a call to the statement list that writes the expressions value:
result.add(newCall("writeln", newIdentNode("stdout"), n[i]))
result.add(newCall("writeLine", newIdentNode("stdout"), n[i]))
var
a: array[0..10, int]
@ -699,15 +699,15 @@ The macro call expands to:
.. code-block:: nim
write(stdout, "a[0]")
write(stdout, ": ")
writeln(stdout, a[0])
writeLine(stdout, a[0])
write(stdout, "a[1]")
write(stdout, ": ")
writeln(stdout, a[1])
writeLine(stdout, a[1])
write(stdout, "x")
write(stdout, ": ")
writeln(stdout, x)
writeLine(stdout, x)

View file

@ -4,4 +4,4 @@ write(stdout, "Content-type: text/html\n\n")
write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
write(stdout, "<html><head><title>Test</title></head><body>\n")
write(stdout, "Hello!")
writeln(stdout, "</body></html>")
writeLine(stdout, "</body></html>")

View file

@ -7,6 +7,6 @@ writeContentType()
write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
write(stdout, "<html><head><title>Test</title></head><body>\n")
writeln(stdout, "name: " & myData["name"])
writeln(stdout, "password: " & myData["password"])
writeln(stdout, "</body></html>")
writeLine(stdout, "name: " & myData["name"])
writeLine(stdout, "password: " & myData["password"])
writeLine(stdout, "</body></html>")

View file

@ -369,7 +369,7 @@ iterator split*(s: string, sep: Regex): string =
##
## .. code-block:: nim
## for word in split("00232this02939is39an22example111", re"\d+"):
## writeln(stdout, word)
## writeLine(stdout, word)
##
## Results in:
##

View file

@ -307,7 +307,7 @@ proc defaultMsgHandler*(filename: string, line, col: int, msgkind: MsgKind,
let a = messages[msgkind] % arg
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
if mc == mcError: raise newException(EParseError, message)
else: writeln(stdout, message)
else: writeLine(stdout, message)
proc defaultFindFile*(filename: string): string {.procvar.} =
if existsFile(filename): result = filename

View file

@ -25,9 +25,9 @@
## # generate content:
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
## write(stdout, "<html><head><title>Test</title></head><body>\n")
## writeln(stdout, "your name: " & myData["name"])
## writeln(stdout, "your password: " & myData["password"])
## writeln(stdout, "</body></html>")
## writeLine(stdout, "your name: " & myData["name"])
## writeLine(stdout, "your password: " & myData["password"])
## writeLine(stdout, "</body></html>")
import strutils, os, strtabs, cookies

View file

@ -132,12 +132,12 @@ method log*(logger: Logger, level: Level, args: varargs[string, `$`]) {.
method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) =
## Logs to the console using ``logger`` only.
if level >= logger.levelThreshold:
writeln(stdout, substituteLog(logger.fmtStr, level, args))
writeLine(stdout, substituteLog(logger.fmtStr, level, args))
method log*(logger: FileLogger, level: Level, args: varargs[string, `$`]) =
## Logs to a file using ``logger`` only.
if level >= logger.levelThreshold:
writeln(logger.f, substituteLog(logger.fmtStr, level, args))
writeLine(logger.f, substituteLog(logger.fmtStr, level, args))
proc defaultFilename*(): string =
## Returns the default filename for a logger.
@ -228,7 +228,7 @@ method log*(logger: RollingFileLogger, level: Level, args: varargs[string, `$`])
logger.curLine = 0
logger.f = open(logger.baseName, logger.baseMode, bufSize = logger.bufSize)
writeln(logger.f, substituteLog(logger.fmtStr, level, args))
writeLine(logger.f, substituteLog(logger.fmtStr, level, args))
logger.curLine.inc
# --------

View file

@ -155,7 +155,7 @@ proc writeProfile() {.noconv.} =
var f: File
if open(f, filename, fmWrite):
sort(profileData, cmpEntries)
writeln(f, "total executions of each stack trace:")
writeLine(f, "total executions of each stack trace:")
var entries = 0
for i in 0..high(profileData):
if profileData[i] != nil: inc entries
@ -175,13 +175,13 @@ proc writeProfile() {.noconv.} =
for i in 0..min(100, entries-1):
if profileData[i].total > 1:
inc sum, profileData[i].total
writeln(f, "Entry: ", i+1, "/", entries, " Calls: ",
writeLine(f, "Entry: ", i+1, "/", entries, " Calls: ",
profileData[i].total // totalCalls, " [sum: ", sum, "; ",
sum // totalCalls, "]")
for ii in 0..high(StackTrace):
let procname = profileData[i].st[ii]
if isNil(procname): break
writeln(f, " ", procname, " ", perProc[$procname] // totalCalls)
writeLine(f, " ", procname, " ", perProc[$procname] // totalCalls)
close(f)
echo "... done"
else:

View file

@ -1323,7 +1323,7 @@ proc ra(n: SqlNode, s: var string, indent: int) =
# where: x.name == y.name
#db.select(fromm = [t1, t2], where = t1.name == t2.name):
#for x, y, z in db.select(fromm = a, b where = a.name == b.name):
# writeln x, y, z
# writeLine x, y, z
proc renderSQL*(n: SqlNode): string =
## Converts an SQL abstract syntax tree to its string representation.

View file

@ -979,7 +979,7 @@ iterator split*(s: string, sep: Peg): string =
##
## .. code-block:: nim
## for word in split("00232this02939is39an22example111", peg"\d+"):
## writeln(stdout, word)
## writeLine(stdout, word)
##
## Results in:
##

View file

@ -117,7 +117,12 @@ proc write*(s: Stream, x: string) =
## terminating zero is written.
writeData(s, cstring(x), x.len)
proc writeln*(s: Stream, args: varargs[string, `$`]) =
proc writeLn*(s: Stream, args: varargs[string, `$`]) {.deprecated.} =
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
for str in args: write(s, str)
write(s, "\n")
proc writeLine*(s: Stream, args: varargs[string, `$`]) =
## writes one or more strings to the the stream `s` followed
## by a new line. No length field or terminating zero is written.
for str in args: write(s, str)

View file

@ -206,7 +206,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
##
## .. code-block:: nim
## for word in split(" this is an example "):
## writeln(stdout, word)
## writeLine(stdout, word)
##
## ...generates this output:
##
@ -220,7 +220,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
##
## .. code-block:: nim
## for word in split(";;this;is;an;;example;;;", {';'}):
## writeln(stdout, word)
## writeLine(stdout, word)
##
## ...produces the same output as the first example. The code:
##
@ -228,7 +228,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
## let date = "2012-11-20T22:08:08.398990"
## let separators = {' ', '-', ':', 'T'}
## for number in split(date, separators):
## writeln(stdout, number)
## writeLine(stdout, number)
##
## ...results in:
##
@ -259,7 +259,7 @@ iterator split*(s: string, sep: char): string =
##
## .. code-block:: nim
## for word in split(";;this;is;an;;example;;;", ';'):
## writeln(stdout, word)
## writeLine(stdout, word)
##
## Results in:
##
@ -309,7 +309,7 @@ iterator splitLines*(s: string): string =
##
## .. code-block:: nim
## for line in splitLines("\nthis\nis\nan\n\nexample\n"):
## writeln(stdout, line)
## writeLine(stdout, line)
##
## Results in:
##
@ -571,7 +571,7 @@ iterator tokenize*(s: string, seps: set[char] = Whitespace): tuple[
##
## .. code-block:: nim
## for word in tokenize(" this is an example "):
## writeln(stdout, word)
## writeLine(stdout, word)
##
## Results in:
##

View file

@ -430,8 +430,8 @@ macro styledEcho*(m: varargs[expr]): stmt =
case item.kind
of nnkStrLit..nnkTripleStrLit:
if i == m.len - 1:
# optimize if string literal is last, just call writeln
result.add(newCall(bindSym"writeln", bindSym"stdout", item))
# optimize if string literal is last, just call writeLine
result.add(newCall(bindSym"writeLine", bindSym"stdout", item))
if reset: result.add(newCall(bindSym"resetAttributes"))
return
else:
@ -470,7 +470,7 @@ when not defined(testing) and isMainModule:
writeStyled("styled text ", {styleBright, styleBlink, styleUnderscore})
setBackGroundColor(bgCyan, true)
setForeGroundColor(fgBlue)
writeln(stdout, "ordinary text")
writeLine(stdout, "ordinary text")
styledEcho("styled text ", {styleBright, styleBlink, styleUnderscore})

View file

@ -898,7 +898,7 @@ proc contains*[T](x: set[T], y: T): bool {.magic: "InSet", noSideEffect.}
##
## .. code-block:: Nim
## var s: set[range['a'..'z']] = {'a'..'c'}
## writeln(stdout, 'b' in s)
## writeLine(stdout, 'b' in s)
##
## If ``in`` had been declared as ``[T](elem: T, s: set[T])`` then ``T`` would
## have been bound to ``char``. But ``s`` is not compatible to type
@ -2269,7 +2269,7 @@ proc echo*(x: varargs[expr, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
## Special built-in that takes a variable number of arguments. Each argument
## is converted to a string via ``$``, so it works for user-defined
## types that have an overloaded ``$`` operator.
## It is roughly equivalent to ``writeln(stdout, x); flushFile(stdout)``, but
## It is roughly equivalent to ``writeLine(stdout, x); flushFile(stdout)``, but
## available for the JavaScript target too.
##
## Unlike other IO operations this is guaranteed to be thread-safe as
@ -2526,7 +2526,11 @@ when not defined(JS): #and not defined(NimrodVM):
## Returns ``false`` if the end of the file has been reached, ``true``
## otherwise. If ``false`` is returned `line` contains no new data.
proc writeln*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
proc writeLn*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
tags: [WriteIOEffect], benign, deprecated.}
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
proc writeLine*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
tags: [WriteIOEffect], benign.}
## writes the values `x` to `f` and then writes "\n".
## May throw an IO exception.

View file

@ -117,7 +117,7 @@ proc dbgRepr(p: pointer, typ: PNimType): string =
proc writeVariable(stream: File, slot: VarSlot) =
write(stream, slot.name)
write(stream, " = ")
writeln(stream, dbgRepr(slot.address, slot.typ))
writeLine(stream, dbgRepr(slot.address, slot.typ))
proc listFrame(stream: File, f: PFrame) =
write(stream, EndbBeg)
@ -125,7 +125,7 @@ proc listFrame(stream: File, f: PFrame) =
write(stream, f.len)
write(stream, " slots):\n")
for i in 0 .. f.len-1:
writeln(stream, getLocal(f, i).name)
writeLine(stream, getLocal(f, i).name)
write(stream, EndbEnd)
proc listLocals(stream: File, f: PFrame) =
@ -141,7 +141,7 @@ proc listGlobals(stream: File) =
write(stream, EndbBeg)
write(stream, "| Globals:\n")
for i in 0 .. getGlobalLen()-1:
writeln(stream, getGlobal(i).name)
writeLine(stream, getGlobal(i).name)
write(stream, EndbEnd)
proc debugOut(msg: cstring) =

View file

@ -208,10 +208,15 @@ proc endOfFile(f: File): bool =
ungetc(c, f)
return c < 0'i32
proc writeln[Ty](f: File, x: varargs[Ty, `$`]) =
proc writeLn[Ty](f: File, x: varargs[Ty, `$`]) =
for i in items(x): write(f, i)
write(f, "\n")
proc writeLine[Ty](f: File, x: varargs[Ty, `$`]) =
for i in items(x): write(f, i)
write(f, "\n")
proc rawEcho(x: string) {.inline, compilerproc.} = write(stdout, x)
proc rawEchoNL() {.inline, compilerproc.} = write(stdout, "\n")

View file

@ -12,7 +12,7 @@ type
proc len(x: TMyType): int {.inline.} = return x.len
proc x(s: TMyType, len: int) =
writeln(stdout, len(s))
writeLine(stdout, len(s))
var
m: TMyType

View file

@ -10,6 +10,6 @@ import mambsym1, times
var
v = mDec #ERROR_MSG ambiguous identifier
writeln(stdout, ord(v))
writeLine(stdout, ord(v))

View file

@ -22,10 +22,10 @@ proc test() =
b = a # perform a deep copy here!
b.seq = @["xyz", "huch", "was", "soll"]
writeln(stdout, len(a.seq))
writeln(stdout, a.seq[3])
writeln(stdout, len(b.seq))
writeln(stdout, b.seq[3])
writeln(stdout, b.y)
writeLine(stdout, len(a.seq))
writeLine(stdout, a.seq[3])
writeLine(stdout, len(b.seq))
writeLine(stdout, b.seq[3])
writeLine(stdout, b.y)
test()

View file

@ -16,8 +16,8 @@ proc main() =
p = find(example, "=")
a = substr(example, 0, p-1)
b = substr(example, p+1)
writeln(stdout, a & '=' & b)
#writeln(stdout, b)
writeLine(stdout, a & '=' & b)
#writeLine(stdout, b)
main()
#OUT TEMP=C:\Programs\xyz\bin

View file

@ -13,7 +13,7 @@ type
proc forw: int {. .}
proc lier(): int {.raises: [IO2Error].} =
writeln stdout, "arg"
writeLine stdout, "arg"
proc forw: int =
raise newException(IOError, "arg")

View file

@ -13,7 +13,7 @@ type
proc forw: int {.raises: [].}
proc lier(): int {.raises: [IOError].} =
writeln stdout, "arg"
writeLine stdout, "arg"
proc forw: int =
raise newException(IOError, "arg")

View file

@ -12,7 +12,7 @@ type
EIO2 = ref object of EIO
proc raiser(): int {.tags: [TObj, FWriteIO].} =
writeln stdout, "arg"
writeLine stdout, "arg"
var o: TObjB
o.fn = raiser

View file

@ -15,7 +15,7 @@ proc q() {.tags: [FIO].} =
nil
proc raiser(): int =
writeln stdout, "arg"
writeLine stdout, "arg"
if true:
q()

View file

@ -63,12 +63,12 @@ proc caseTree(lvl: int = 0): PCaseNode =
if lvl == 3: result = newCaseNode("data item")
else: result = newCaseNode(caseTree(lvl+1), caseTree(lvl+1))
proc finalizeBNode(n: TBNode) = writeln(stdout, n.data)
proc finalizeBNode(n: TBNode) = writeLine(stdout, n.data)
proc finalizeNode(n: PNode) =
assert(n != nil)
write(stdout, "finalizing: ")
if isNil(n.data): writeln(stdout, "nil!")
else: writeln(stdout, n.data)
if isNil(n.data): writeLine(stdout, "nil!")
else: writeLine(stdout, n.data)
var
id: int = 1
@ -82,7 +82,7 @@ proc buildTree(depth = 1): PNode =
inc(id)
proc returnTree(): PNode =
writeln(stdout, "creating id: " & $id)
writeLine(stdout, "creating id: " & $id)
new(result, finalizeNode)
result.data = $id
new(result.le, finalizeNode)
@ -92,26 +92,26 @@ proc returnTree(): PNode =
inc(id)
# now create a cycle:
writeln(stdout, "creating id (cyclic): " & $id)
writeLine(stdout, "creating id (cyclic): " & $id)
var cycle: PNode
new(cycle, finalizeNode)
cycle.data = $id
cycle.le = cycle
cycle.ri = cycle
inc(id)
#writeln(stdout, "refcount: " & $refcount(cycle))
#writeln(stdout, "refcount le: " & $refcount(cycle.le))
#writeln(stdout, "refcount ri: " & $refcount(cycle.ri))
#writeLine(stdout, "refcount: " & $refcount(cycle))
#writeLine(stdout, "refcount le: " & $refcount(cycle.le))
#writeLine(stdout, "refcount ri: " & $refcount(cycle.ri))
proc printTree(t: PNode) =
if t == nil: return
writeln(stdout, "printing")
writeln(stdout, t.data)
writeLine(stdout, "printing")
writeLine(stdout, t.data)
printTree(t.le)
printTree(t.ri)
proc unsureNew(result: var PNode) =
writeln(stdout, "creating unsure id: " & $id)
writeLine(stdout, "creating unsure id: " & $id)
new(result, finalizeNode)
result.data = $id
new(result.le, finalizeNode)
@ -176,7 +176,7 @@ proc main() =
var s: seq[string] = @[]
for i in 1..100:
add s, "hohoho" # test reallocation
writeln(stdout, s[89])
writeLine(stdout, s[89])
write(stdout, "done!\n")
var
@ -184,7 +184,7 @@ var
s: string
s = ""
s = ""
writeln(stdout, repr(caseTree()))
writeLine(stdout, repr(caseTree()))
father.t.data = @["ha", "lets", "stress", "it"]
father.t.data = @["ha", "lets", "stress", "it"]
var t = buildTree()
@ -199,5 +199,5 @@ GC_fullCollect()
# the M&S GC fails with this call and it's unclear why. Definitely something
# we need to fix!
GC_fullCollect()
writeln(stdout, GC_getStatistics())
writeLine(stdout, GC_getStatistics())
write(stdout, "finished\n")

View file

@ -15,7 +15,7 @@ if find(root, "world"):
for str in items(root):
stdout.write(str)
else:
stdout.writeln("BUG")
stdout.writeLine("BUG")
var
r2: PBinaryTree[int]

View file

@ -92,7 +92,7 @@ when isMainModule:
for str in items(root):
stdout.write(str)
else:
stdout.writeln("BUG")
stdout.writeLine("BUG")
var
r2: PBinaryTree[int]

View file

@ -184,7 +184,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
proc traceln(space: string) =
writeln stdout, ""
writeLine stdout, ""
write stdout, space
proc doTrace(n: PNode[T,D], level: int) =
@ -192,7 +192,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
traceln(space)
write stdout, "node: "
if n == nil:
writeln stdout, "is empty"
writeLine stdout, "is empty"
return
write stdout, n.count
write stdout, " elements: "
@ -219,7 +219,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
else : write stdout, el.key
if el.node != nil: doTrace(el.node, level +1)
else : write stdout, " empty "
writeln stdout,""
writeLine stdout,""
doTrace(root, 0)

View file

@ -50,8 +50,8 @@ proc main*(infile: string, a, b: int, someverylongnamewithtype = 0,
# this should be an error!
if initBaseLexer(L, infile, 30): nil
else:
writeln(stdout, "could not open: " & infile)
writeln(stdout, "Success!")
writeLine(stdout, "could not open: " & infile)
writeLine(stdout, "Success!")
call(3, # we use 3
12, # we use 12
43) # we use 43

View file

@ -18,7 +18,7 @@ macro debug(n: varargs[expr]): stmt =
# add a call to the statement list that writes ": "
add(result, newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
# add a call to the statement list that writes the expressions value:
add(result, newCall("writeln", newIdentNode("stdout"), n[i]))
add(result, newCall("writeLine", newIdentNode("stdout"), n[i]))
var
a: array [0..10, int]

View file

@ -7,8 +7,8 @@ var
i: int
params = paramCount()
i = 0
writeln(stdout, "This exe: " & getAppFilename())
writeln(stdout, "Number of parameters: " & $params)
writeLine(stdout, "This exe: " & getAppFilename())
writeLine(stdout, "Number of parameters: " & $params)
while i <= params:
writeln(stdout, paramStr(i))
writeLine(stdout, paramStr(i))
i = i + 1

View file

@ -1,3 +1,3 @@
# test the new endian magic
writeln(stdout, repr(system.cpuEndian))
writeLine(stdout, repr(system.cpuEndian))

View file

@ -22,7 +22,7 @@ macro macrotest(n: expr): stmt {.immediate.} =
result = newNimNode(nnkStmtList, n)
for i in 2..n.len-1:
result.add(newCall("write", n[1], n[i]))
result.add(newCall("writeln", n[1], newStrLitNode("")))
result.add(newCall("writeLine", n[1], newStrLitNode("")))
macro debug(n: expr): stmt {.immediate.} =
let n = callsite()
@ -30,7 +30,7 @@ macro debug(n: expr): stmt {.immediate.} =
for i in 1..n.len-1:
result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
result.add(newCall("writeln", newIdentNode("stdout"), n[i]))
result.add(newCall("writeLine", newIdentNode("stdout"), n[i]))
macrotest(stdout, "finally", 4, 5, "variable", "argument lists")
macrotest(stdout)
@ -38,7 +38,7 @@ macrotest(stdout)
#GC_disable()
echo("This was compiled by Nim version " & system.NimVersion)
writeln(stdout, "Hello", " World", "!")
writeLine(stdout, "Hello", " World", "!")
echo(["a", "b", "c", "d"].len)
for x in items(["What's", "your", "name", "?", ]):

View file

@ -8,8 +8,8 @@ proc main() =
a, b: TTime
a = getLastModificationTime(paramStr(1))
b = getLastModificationTime(paramStr(2))
writeln(stdout, $a)
writeln(stdout, $b)
writeLine(stdout, $a)
writeLine(stdout, $b)
if a < b:
write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)])
else:

View file

@ -24,10 +24,10 @@ var size = parseInt (paramStr (1))
var bit = 128
var byteAcc = 0
stdout.writeln ("P4")
stdout.writeLine ("P4")
stdout.write ($size)
stdout.write (" ")
stdout.writeln ($size)
stdout.writeLine ($size)
var fsize = float (size)
for y in 0 .. size-1:

View file

@ -9,4 +9,4 @@ var
x = 1
y = high(int)
writeln(stdout, $ ( x +% y ) )
writeLine(stdout, $ ( x +% y ) )

View file

@ -91,9 +91,9 @@ proc t64(i: int64) =
toVarNum64(i, b)
var x = toNum64(b)
if x != i:
writeln(stdout, $i)
writeln(stdout, toBinary(i))
writeln(stdout, toBinary(x))
writeLine(stdout, $i)
writeLine(stdout, toBinary(i))
writeLine(stdout, toBinary(x))
proc t32(i: int32) =
var
@ -101,8 +101,8 @@ proc t32(i: int32) =
toVarNum(i, b)
var x = toNum(b)
if x != i:
writeln(stdout, toBinary(i))
writeln(stdout, toBinary(x))
writeLine(stdout, toBinary(i))
writeLine(stdout, toBinary(x))
proc tm(i: int32) =
var
@ -110,8 +110,8 @@ proc tm(i: int32) =
toVarNum64(i, b)
var x = toNum(b)
if x != i:
writeln(stdout, toBinary(i))
writeln(stdout, toBinary(x))
writeLine(stdout, toBinary(i))
writeLine(stdout, toBinary(x))
t32(0)
t32(1)
@ -137,6 +137,6 @@ tm(100_000)
tm(low(int32))
tm(high(int32))
writeln(stdout, "Success!") #OUT Success!
writeLine(stdout, "Success!") #OUT Success!

View file

@ -9,7 +9,7 @@ type
proc getPoint( p: var TPoint2d) =
{.breakpoint.}
writeln(stdout, p.x)
writeLine(stdout, p.x)
var
p: TPoint3d

View file

@ -16,7 +16,7 @@ type
TCircle = object of TFigure
radius: int
proc drawCircle(my: var TCircle) = stdout.writeln("o " & $my.radius)
proc drawCircle(my: var TCircle) = stdout.writeLine("o " & $my.radius)
proc init(my: var TCircle) =
init(TFigure(my)) # call base constructor

View file

@ -11,9 +11,9 @@ var
a = high(int)
b = -2
try:
writeln(stdout, b - a)
writeLine(stdout, b - a)
except OverflowError:
writeln(stdout, "the computation overflowed")
writeLine(stdout, "the computation overflowed")
{.pop.} # overflow check
#OUT the computation overflowed

View file

@ -58,7 +58,7 @@ for x in low(TAZ) .. high(TAZ):
for x in low(TTokTypeRange) .. high(TTokTypeRange):
if x in tokTypes:
discard
#writeln(stdout, "the token '$1' is in the set" % repr(x))
#writeLine(stdout, "the token '$1' is in the set" % repr(x))
#OUT Ha ein F ist in s!

View file

@ -2,6 +2,6 @@
proc main() =
for line in lines("thello.nim"):
writeln(stdout, line)
writeLine(stdout, line)
main()

View file

@ -4,10 +4,10 @@ import
parseopt
proc writeHelp() =
writeln(stdout, "Usage: tparsopt [options] filename [options]")
writeLine(stdout, "Usage: tparsopt [options] filename [options]")
proc writeVersion() =
writeln(stdout, "Version: 1.0.0")
writeLine(stdout, "Version: 1.0.0")
var
filename = ""
@ -20,7 +20,7 @@ for kind, key, val in getopt():
of "help", "h": writeHelp()
of "version", "v": writeVersion()
else:
writeln(stdout, "Unknown command line option: ", key, ": ", val)
writeLine(stdout, "Unknown command line option: ", key, ": ", val)
of cmdEnd: assert(false) # cannot happen
if filename == "":
# no filename has been given, so we show the help:

View file

@ -981,7 +981,7 @@ iterator split*(s: string, sep: TPeg): string =
##
## .. code-block:: nim
## for word in split("00232this02939is39an22example111", peg"\d+"):
## writeln(stdout, word)
## writeLine(stdout, word)
##
## Results in:
##
@ -1682,7 +1682,7 @@ when isMainModule:
doAssert "ABC".match(peg"\d+ / \w+")
for word in split("00232this02939is39an22example111", peg"\d+"):
writeln(stdout, word)
writeLine(stdout, word)
doAssert matchLen("key", ident) == 3

View file

@ -9,8 +9,8 @@ when not defined(windows):
discard uname(u)
writeln(stdout, u.sysname)
writeln(stdout, u.nodename)
writeln(stdout, u.release)
writeln(stdout, u.machine)
writeLine(stdout, u.sysname)
writeLine(stdout, u.nodename)
writeLine(stdout, u.release)
writeLine(stdout, u.machine)

View file

@ -9,7 +9,7 @@ type
var val = {a, b}
stdout.write(repr(val))
stdout.writeln(repr({'a'..'z', 'A'..'Z'}))
stdout.writeLine(repr({'a'..'z', 'A'..'Z'}))
type
TObj {.pure, inheritable.} = object

View file

@ -26,7 +26,7 @@ q[] = p
s = @[q, q, q, q]
writeln(stdout, repr(p))
writeln(stdout, repr(q))
writeln(stdout, repr(s))
writeln(stdout, repr(en4))
writeLine(stdout, repr(p))
writeLine(stdout, repr(q))
writeLine(stdout, repr(s))
writeLine(stdout, repr(en4))

View file

@ -6,7 +6,7 @@ for i in 0..80:
tab["key_" & $i] = "value" & $i
for key, val in pairs(tab):
writeln(stdout, key, ": ", val)
writeln(stdout, "length of table ", $tab.len)
writeLine(stdout, key, ": ", val)
writeLine(stdout, "length of table ", $tab.len)
writeln(stdout, `%`("$key1 = $key2; ${PATH}", tab, {useEnvironment}))
writeLine(stdout, `%`("$key1 = $key2; ${PATH}", tab, {useEnvironment}))

View file

@ -5,9 +5,9 @@ import
proc main(filter: string) =
for filename in walkFiles(filter):
writeln(stdout, filename)
writeLine(stdout, filename)
for key, val in envPairs():
writeln(stdout, key & '=' & val)
writeLine(stdout, key & '=' & val)
main("*.nim")

View file

@ -15,10 +15,10 @@ var abclev = levB
template tstLev(abclev: TLev) =
bind tstempl.abclev, `%`
writeln(stdout, "global = $1, arg = $2, test = $3" % [
writeLine(stdout, "global = $1, arg = $2, test = $3" % [
$tstempl.abclev, $abclev, $(tstempl.abclev == abclev)])
# evaluates to true, but must be false
tstLev(levA)
writeln(stdout, $abclev)
writeLine(stdout, $abclev)

View file

@ -13,8 +13,8 @@ template withOpenFile(f: expr, filename: string, mode: TFileMode,
quit("cannot open for writing: " & filename)
withOpenFile(txt, "ttempl3.txt", fmWrite):
writeln(txt, "line 1")
txt.writeln("line 2")
writeLine(txt, "line 1")
txt.writeLine("line 2")
var
myVar: array[0..1, int]

View file

@ -137,11 +137,11 @@ proc doScenario(script: string, output: Stream, mode: TRunMode, verbose: bool):
if line.strip.len == 0: continue
if line.startsWith("#"):
output.writeln line
output.writeLine line
continue
elif line.startsWith(">"):
s.doCommand(line.substr(1).strip)
output.writeln line, "\n", if verbose: s.lastOutput else: ""
output.writeLine line, "\n", if verbose: s.lastOutput else: ""
else:
var expectMatch = true
var pattern = s.replaceVars(line)
@ -153,9 +153,9 @@ proc doScenario(script: string, output: Stream, mode: TRunMode, verbose: bool):
s.lastOutput.find(re(pattern, flags = {reStudy})) != -1
if expectMatch == actualMatch:
output.writeln "SUCCESS ", line
output.writeLine "SUCCESS ", line
else:
output.writeln "FAILURE ", line
output.writeLine "FAILURE ", line
result = false
iterator caasTestsRunner*(filter = "", verbose = false): tuple[test,

View file

@ -138,7 +138,7 @@ proc generateHtml*(filename: string, commit: int; onlyFailing: bool) =
# generate navigation:
outfile.write("""<ul id="tabs">""")
for m in db.rows(sql"select id, name, os, cpu from Machine order by id"):
outfile.writeln """<li><a href="#$#">$#: $#, $#</a></li>""" % m
outfile.writeLine """<li><a href="#$#">$#: $#, $#</a></li>""" % m
outfile.write("</ul>")
for currentMachine in db.rows(sql"select id from Machine order by id"):
@ -195,7 +195,7 @@ proc generateJson*(filename: string, commit: int) =
let machine = $backend.getMachine(db)
let data = db.getRow(sql(selRow), lastCommit, machine)
outfile.writeln("""{"total": $#, "passed": $#, "skipped": $#""" % data)
outfile.writeLine("""{"total": $#, "passed": $#, "skipped": $#""" % data)
let results = newJArray()
for row in db.rows(sql(selResults), lastCommit):
@ -208,7 +208,7 @@ proc generateJson*(filename: string, commit: int) =
obj["expected"] = %row[5]
obj["given"] = %row[6]
results.add(obj)
outfile.writeln(""", "results": """)
outfile.writeLine(""", "results": """)
outfile.write(results.pretty)
if not previousCommit.isNil:
@ -220,9 +220,9 @@ proc generateJson*(filename: string, commit: int) =
obj["old"] = %row[1]
obj["new"] = %row[2]
diff.add obj
outfile.writeln(""", "diff": """)
outfile.writeln(diff.pretty)
outfile.writeLine(""", "diff": """)
outfile.writeLine(diff.pretty)
outfile.writeln "}"
outfile.writeLine "}"
close(db)
close(outfile)

View file

@ -4,6 +4,6 @@ discard """
proc f(x: varargs[string, `$`]) = discard
template optF{f(x)}(x: varargs[expr]) =
writeln(stdout, x)
writeLine(stdout, x)
f 1, 2, false, 3, "ha"

View file

@ -7,13 +7,13 @@ discard """
template optWrite{
write(f, x)
((write|writeln){w})(f, y)
((write|writeLine){w})(f, y)
}(x, y: varargs[expr], f, w: expr) =
w(f, "|", x, y, "|")
if true:
echo "0"
write stdout, "1"
writeln stdout, "2"
writeLine stdout, "2"
write stdout, "3"
echo "4"

View file

@ -19,9 +19,9 @@ proc process(dir, infile: string, outfile: File,
ig <- (comment / \s+)* """:
# follow the include file:
if process(dir, matches[0], outfile, processed) == prAddIncludeDir:
writeln(outfile, line)
writeLine(outfile, line)
else:
writeln(outfile, line)
writeLine(outfile, line)
proc main(dir, outfile: string) =
var o: File

View file

@ -119,7 +119,7 @@ proc processFile(filename: string) =
var filenameShown = false
template beforeHighlight =
if not filenameShown and optVerbose notin options:
stdout.writeln(filename)
stdout.writeLine(filename)
filenameShown = true
var buffer: string
@ -128,7 +128,7 @@ proc processFile(filename: string) =
except IOError:
echo "cannot open file: ", filename
return
if optVerbose in options: stdout.writeln(filename)
if optVerbose in options: stdout.writeLine(filename)
var pegp: TPeg
var rep: Regex
var result: string

View file

@ -431,7 +431,7 @@ proc buildWebsite(c: var TConfigData) =
if not existsDir("web/upload"):
createDir("web/upload")
if open(f, outfile, fmWrite):
writeln(f, generateHTMLPage(c, file, content, rss))
writeLine(f, generateHTMLPage(c, file, content, rss))
close(f)
else:
quit("[Error] cannot write file: " & outfile)