Nimrod renamed to Nim

This commit is contained in:
Araq 2014-08-28 09:59:26 +02:00
commit 4523b29d7a
23 changed files with 90 additions and 90 deletions

View file

@ -261,7 +261,7 @@ proc getAst*(macroOrTemplate: expr): PNimrodNode {.magic: "ExpandToAst", noSideE
## Obtains the AST nodes returned from a macro or template invocation. ## Obtains the AST nodes returned from a macro or template invocation.
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## macro FooMacro() = ## macro FooMacro() =
## var ast = getAst(BarTemplate()) ## var ast = getAst(BarTemplate())
@ -278,7 +278,7 @@ proc quote*(bl: stmt, op = "``"): PNimrodNode {.magic: "QuoteAst", noSideEffect.
## ##
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## macro check(ex: expr): stmt = ## macro check(ex: expr): stmt =
## # this is a simplified version of the check macro from the ## # this is a simplified version of the check macro from the
@ -422,7 +422,7 @@ proc lispRepr*(n: PNimrodNode): string {.compileTime.} =
add(result, ")") add(result, ")")
macro dumpTree*(s: stmt): stmt {.immediate.} = echo s.treeRepr macro dumpTree*(s: stmt): stmt {.immediate.} = echo s.treeRepr
## Accepts a block of nimrod code and prints the parsed abstract syntax ## Accepts a block of nim code and prints the parsed abstract syntax
## tree using the `toTree` function. Printing is done *at compile time*. ## tree using the `toTree` function. Printing is done *at compile time*.
## ##
## You can use this as a tool to explore the Nimrod's abstract syntax ## You can use this as a tool to explore the Nimrod's abstract syntax
@ -430,7 +430,7 @@ macro dumpTree*(s: stmt): stmt {.immediate.} = echo s.treeRepr
## a certain expression/statement. ## a certain expression/statement.
macro dumpLisp*(s: stmt): stmt {.immediate.} = echo s.lispRepr macro dumpLisp*(s: stmt): stmt {.immediate.} = echo s.lispRepr
## Accepts a block of nimrod code and prints the parsed abstract syntax ## Accepts a block of nim code and prints the parsed abstract syntax
## tree using the `toLisp` function. Printing is done *at compile time*. ## tree using the `toLisp` function. Printing is done *at compile time*.
## ##
## See `dumpTree`. ## See `dumpTree`.
@ -489,7 +489,7 @@ proc newIdentDefs*(name, kind: PNimrodNode;
## ``let`` or ``var`` blocks may have an empty ``kind`` node if the ## ``let`` or ``var`` blocks may have an empty ``kind`` node if the
## identifier is being assigned a value. Example: ## identifier is being assigned a value. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## var varSection = newNimNode(nnkVarSection).add( ## var varSection = newNimNode(nnkVarSection).add(
## newIdentDefs(ident("a"), ident("string")), ## newIdentDefs(ident("a"), ident("string")),
@ -501,7 +501,7 @@ proc newIdentDefs*(name, kind: PNimrodNode;
## If you need to create multiple identifiers you need to use the lower level ## If you need to create multiple identifiers you need to use the lower level
## ``newNimNode``: ## ``newNimNode``:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## result = newNimNode(nnkIdentDefs).add( ## result = newNimNode(nnkIdentDefs).add(
## ident("a"), ident("b"), ident("c"), ident("string"), ## ident("a"), ident("b"), ident("c"), ident("string"),
@ -549,7 +549,7 @@ proc newIfStmt*(branches: varargs[tuple[cond, body: PNimrodNode]]):
PNimrodNode {.compiletime.} = PNimrodNode {.compiletime.} =
## Constructor for ``if`` statements. ## Constructor for ``if`` statements.
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## newIfStmt( ## newIfStmt(
## (Ident, StmtList), ## (Ident, StmtList),
@ -643,7 +643,7 @@ template findChild*(n: PNimrodNode; cond: expr): PNimrodNode {.
immediate, dirty.} = immediate, dirty.} =
## Find the first child node matching condition (or nil). ## Find the first child node matching condition (or nil).
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var res = findChild(n, it.kind == nnkPostfix and ## var res = findChild(n, it.kind == nnkPostfix and
## it.basename.ident == !"foo") ## it.basename.ident == !"foo")
block: block:
@ -738,11 +738,11 @@ proc addIdentIfAbsent*(dest: PNimrodNode, ident: string) {.compiletime.} =
when not defined(booting): when not defined(booting):
template emit*(e: static[string]): stmt = template emit*(e: static[string]): stmt =
## accepts a single string argument and treats it as nimrod code ## accepts a single string argument and treats it as nim code
## that should be inserted verbatim in the program ## that should be inserted verbatim in the program
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## emit("echo " & '"' & "hello world".toUpper & '"') ## emit("echo " & '"' & "hello world".toUpper & '"')
## ##
macro payload: stmt {.gensym.} = macro payload: stmt {.gensym.} =

View file

@ -50,7 +50,7 @@ type
akUInt32 = 43, ## any represents an unsigned int32 akUInt32 = 43, ## any represents an unsigned int32
akUInt64 = 44, ## any represents an unsigned int64 akUInt64 = 44, ## any represents an unsigned int64
TAny* = object {.pure.} ## can represent any nimrod value; NOTE: the wrapped TAny* = object {.pure.} ## can represent any nim value; NOTE: the wrapped
## value can be modified with its wrapper! This means ## value can be modified with its wrapper! This means
## that ``TAny`` keeps a non-traced pointer to its ## that ``TAny`` keeps a non-traced pointer to its
## wrapped value and **must not** live longer than ## wrapped value and **must not** live longer than

View file

@ -186,7 +186,7 @@ proc open*(connection, user, password, database: string): TDbConn {.
## ##
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## con = Open("", "", "", "host=localhost port=5432 dbname=mydb") ## con = Open("", "", "", "host=localhost port=5432 dbname=mydb")
## ##
@ -194,7 +194,7 @@ proc open*(connection, user, password, database: string): TDbConn {.
## for more information. ## for more information.
## ##
## Note that the connection parameter is not used but exists to maintain ## Note that the connection parameter is not used but exists to maintain
## the nimrod db api. ## the nim db api.
result = PQsetdbLogin(nil, nil, nil, nil, database, user, password) result = PQsetdbLogin(nil, nil, nil, nil, database, user, password)
if PQStatus(result) != CONNECTION_OK: dbError(result) # result = nil if PQStatus(result) != CONNECTION_OK: dbError(result) # result = nil

View file

@ -228,7 +228,7 @@ template `=~` *(s: string, pattern: TRegex): expr =
## This calls ``match`` with an implicit declared ``matches`` array that ## This calls ``match`` with an implicit declared ``matches`` array that
## can be used in the scope of the ``=~`` call: ## can be used in the scope of the ``=~`` call:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## if line =~ re"\s*(\w+)\s*\=\s*(\w+)": ## if line =~ re"\s*(\w+)\s*\=\s*(\w+)":
## # matches a key=value pair: ## # matches a key=value pair:
@ -271,12 +271,12 @@ proc replace*(s: string, sub: TRegex, by = ""): string =
## Replaces `sub` in `s` by the string `by`. Captures cannot be ## Replaces `sub` in `s` by the string `by`. Captures cannot be
## accessed in `by`. Examples: ## accessed in `by`. Examples:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## "var1=key; var2=key2".replace(re"(\w+)'='(\w+)") ## "var1=key; var2=key2".replace(re"(\w+)'='(\w+)")
## ##
## Results in: ## Results in:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## "; " ## "; "
result = "" result = ""
@ -293,12 +293,12 @@ proc replacef*(s: string, sub: TRegex, by: string): string =
## Replaces `sub` in `s` by the string `by`. Captures can be accessed in `by` ## Replaces `sub` in `s` by the string `by`. Captures can be accessed in `by`
## with the notation ``$i`` and ``$#`` (see strutils.`%`). Examples: ## with the notation ``$i`` and ``$#`` (see strutils.`%`). Examples:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## "var1=key; var2=key2".replacef(re"(\w+)'='(\w+)", "$1<-$2$2") ## "var1=key; var2=key2".replacef(re"(\w+)'='(\w+)", "$1<-$2$2")
## ##
## Results in: ## Results in:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## "var1<-keykey; val2<-key2key2" ## "var1<-keykey; val2<-key2key2"
result = "" result = ""
@ -360,13 +360,13 @@ iterator split*(s: string, sep: TRegex): string =
## Substrings are separated by the regular expression `sep`. ## Substrings are separated by the regular expression `sep`.
## Examples: ## Examples:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## for word in split("00232this02939is39an22example111", re"\d+"): ## for word in split("00232this02939is39an22example111", re"\d+"):
## writeln(stdout, word) ## writeln(stdout, word)
## ##
## Results in: ## Results in:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## "this" ## "this"
## "is" ## "is"
## "an" ## "an"

View file

@ -8,7 +8,7 @@
# #
## This module provides an easy to use sockets-style ## This module provides an easy to use sockets-style
## nimrod interface to the OpenSSL library. ## nim interface to the OpenSSL library.
{.deprecated.} {.deprecated.}

View file

@ -59,5 +59,5 @@ proc URLretrieveString*(url: string): TaintedString =
result = stream.data.TaintedString result = stream.data.TaintedString
when isMainModule: when isMainModule:
echo URLretrieveString("http://nimrod-code.org/") echo URLretrieveString("http://nim-code.org/")

View file

@ -10,12 +10,12 @@
## This is an include file that simply imports common modules for your ## This is an include file that simply imports common modules for your
## convenience: ## convenience:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## include prelude ## include prelude
## ##
## Same as: ## Same as:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## import os, strutils, times, parseutils, parseopt, hashes, tables, sets ## import os, strutils, times, parseutils, parseopt, hashes, tables, sets
import os, strutils, times, parseutils, parseopt, hashes, tables, sets import os, strutils, times, parseutils, parseopt, hashes, tables, sets

View file

@ -13,7 +13,7 @@
## ##
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## var ## var
## a: TActorPool[int, void] ## a: TActorPool[int, void]

View file

@ -159,7 +159,7 @@ proc sort*[T](a: var openArray[T],
## sensible default argument for ``cmp``, so you have to provide one ## sensible default argument for ``cmp``, so you have to provide one
## of your own. However, the ``system.cmp`` procs can be used: ## of your own. However, the ``system.cmp`` procs can be used:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## sort(myIntArray, system.cmp[int]) ## sort(myIntArray, system.cmp[int])
## ##
@ -170,7 +170,7 @@ proc sort*[T](a: var openArray[T],
## You can inline adhoc comparison procs with the `do notation ## You can inline adhoc comparison procs with the `do notation
## <manual.html#do-notation>`_. Example: ## <manual.html#do-notation>`_. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## people.sort do (x, y: Person) -> int: ## people.sort do (x, y: Person) -> int:
## result = cmp(x.surname, y.surname) ## result = cmp(x.surname, y.surname)

View file

@ -15,7 +15,7 @@
## ##
## The following example demonstrates a simple chat server. ## The following example demonstrates a simple chat server.
## ##
## .. code-block::nimrod ## .. code-block::nim
## ##
## import asyncnet, asyncdispatch ## import asyncnet, asyncdispatch
## ##

View file

@ -1,4 +1,4 @@
#nimrod c -t:-march=i686 --cpu:amd64 --threads:on -d:release lockfreehash.nim #nim c -t:-march=i686 --cpu:amd64 --threads:on -d:release lockfreehash.nim
import unsigned, math, hashes import unsigned, math, hashes

View file

@ -53,7 +53,7 @@ proc createProcType(p, b: PNimrodNode): PNimrodNode {.compileTime.} =
macro `=>`*(p, b: expr): expr {.immediate.} = macro `=>`*(p, b: expr): expr {.immediate.} =
## Syntax sugar for anonymous procedures. ## Syntax sugar for anonymous procedures.
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## proc passTwoAndTwo(f: (int, int) -> int): int = ## proc passTwoAndTwo(f: (int, int) -> int): int =
## f(2, 2) ## f(2, 2)
@ -104,7 +104,7 @@ macro `=>`*(p, b: expr): expr {.immediate.} =
macro `->`*(p, b: expr): expr {.immediate.} = macro `->`*(p, b: expr): expr {.immediate.} =
## Syntax sugar for procedure types. ## Syntax sugar for procedure types.
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## proc pass2(f: (float, float) -> float): float = ## proc pass2(f: (float, float) -> float): float =
## f(2, 2) ## f(2, 2)

View file

@ -656,17 +656,17 @@ when isMainModule:
resp = await client.request("http://picheta.me/aboutme.html") resp = await client.request("http://picheta.me/aboutme.html")
echo("Got response: ", resp.status) echo("Got response: ", resp.status)
resp = await client.request("http://nimrod-lang.org/") resp = await client.request("http://nim-lang.org/")
echo("Got response: ", resp.status) echo("Got response: ", resp.status)
resp = await client.request("http://nimrod-lang.org/download.html") resp = await client.request("http://nim-lang.org/download.html")
echo("Got response: ", resp.status) echo("Got response: ", resp.status)
asyncCheck main() asyncCheck main()
runForever() runForever()
else: else:
#downloadFile("http://force7.de/nimrod/index.html", "nimrodindex.html") #downloadFile("http://force7.de/nim/index.html", "nimindex.html")
#downloadFile("http://www.httpwatch.com/", "ChunkTest.html") #downloadFile("http://www.httpwatch.com/", "ChunkTest.html")
#downloadFile("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com", #downloadFile("http://validator.w3.org/check?uri=http%3A%2F%2Fgoogle.com",
# "validator.html") # "validator.html")

View file

@ -11,7 +11,7 @@
## ##
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## import strutils, sockets, httpserver ## import strutils, sockets, httpserver
## ##
## var counter = 0 ## var counter = 0

View file

@ -16,7 +16,7 @@
## ##
## Usage example: ## Usage example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## let ## let
## small_json = """{"test": 1.3, "key2": true}""" ## small_json = """{"test": 1.3, "key2": true}"""
## jobj = parseJson(small_json) ## jobj = parseJson(small_json)
@ -26,7 +26,7 @@
## ##
## Results in: ## Results in:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## 1.3000000000000000e+00 ## 1.3000000000000000e+00
## true ## true

View file

@ -514,12 +514,12 @@ proc joinPath*(head, tail: string): string {.
## ##
## For example on Unix: ## For example on Unix:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## joinPath("usr", "lib") ## joinPath("usr", "lib")
## ##
## results in: ## results in:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## "usr/lib" ## "usr/lib"
## ##
## If head is the empty string, tail is returned. If tail is the empty ## If head is the empty string, tail is returned. If tail is the empty
@ -528,7 +528,7 @@ proc joinPath*(head, tail: string): string {.
## path separators not located on boundaries won't be modified. More ## path separators not located on boundaries won't be modified. More
## examples on Unix: ## examples on Unix:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## assert joinPath("usr", "") == "usr/" ## assert joinPath("usr", "") == "usr/"
## assert joinPath("", "lib") == "lib" ## assert joinPath("", "lib") == "lib"
## assert joinPath("", "/lib") == "/lib" ## assert joinPath("", "/lib") == "/lib"
@ -560,7 +560,7 @@ proc `/` * (head, tail: string): string {.noSideEffect.} =
## ##
## Here are some examples for Unix: ## Here are some examples for Unix:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## assert "usr" / "" == "usr/" ## assert "usr" / "" == "usr/"
## assert "" / "lib" == "lib" ## assert "" / "lib" == "lib"
## assert "" / "/lib" == "/lib" ## assert "" / "/lib" == "/lib"
@ -574,7 +574,7 @@ proc splitPath*(path: string): tuple[head, tail: string] {.
## ##
## Examples: ## Examples:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## splitPath("usr/local/bin") -> ("usr/local", "bin") ## splitPath("usr/local/bin") -> ("usr/local", "bin")
## splitPath("usr/local/bin/") -> ("usr/local/bin", "") ## splitPath("usr/local/bin/") -> ("usr/local/bin", "")
## splitPath("bin") -> ("", "bin") ## splitPath("bin") -> ("", "bin")
@ -674,10 +674,10 @@ proc splitFile*(path: string): tuple[dir, name, ext: string] {.
## ##
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var (dir, name, ext) = splitFile("usr/local/nimrodc.html") ## var (dir, name, ext) = splitFile("usr/local/nimc.html")
## assert dir == "usr/local" ## assert dir == "usr/local"
## assert name == "nimrodc" ## assert name == "nimc"
## assert ext == ".html" ## assert ext == ".html"
## ##
## If `path` has no extension, `ext` is the empty string. ## If `path` has no extension, `ext` is the empty string.
@ -1579,7 +1579,7 @@ proc inclFilePermissions*(filename: string,
rtl, extern: "nos$1", tags: [ReadDirEffect, WriteDirEffect].} = rtl, extern: "nos$1", tags: [ReadDirEffect, WriteDirEffect].} =
## a convenience procedure for: ## a convenience procedure for:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## setFilePermissions(filename, getFilePermissions(filename)+permissions) ## setFilePermissions(filename, getFilePermissions(filename)+permissions)
setFilePermissions(filename, getFilePermissions(filename)+permissions) setFilePermissions(filename, getFilePermissions(filename)+permissions)
@ -1588,7 +1588,7 @@ proc exclFilePermissions*(filename: string,
rtl, extern: "nos$1", tags: [ReadDirEffect, WriteDirEffect].} = rtl, extern: "nos$1", tags: [ReadDirEffect, WriteDirEffect].} =
## a convenience procedure for: ## a convenience procedure for:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## setFilePermissions(filename, getFilePermissions(filename)-permissions) ## setFilePermissions(filename, getFilePermissions(filename)-permissions)
setFilePermissions(filename, getFilePermissions(filename)-permissions) setFilePermissions(filename, getFilePermissions(filename)-permissions)
@ -1627,7 +1627,7 @@ when defined(nimdoc):
## can test for its availability with `declared() <system.html#declared>`_. ## can test for its availability with `declared() <system.html#declared>`_.
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## when declared(paramCount): ## when declared(paramCount):
## # Use paramCount() here ## # Use paramCount() here
## else: ## else:
@ -1650,7 +1650,7 @@ when defined(nimdoc):
## can test for its availability with `declared() <system.html#declared>`_. ## can test for its availability with `declared() <system.html#declared>`_.
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## when declared(paramStr): ## when declared(paramStr):
## # Use paramStr() here ## # Use paramStr() here
## else: ## else:
@ -1703,7 +1703,7 @@ when declared(paramCount) or defined(nimdoc):
## can test for its availability with `declared() <system.html#declared>`_. ## can test for its availability with `declared() <system.html#declared>`_.
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## when declared(commandLineParams): ## when declared(commandLineParams):
## # Use commandLineParams() here ## # Use commandLineParams() here
## else: ## else:
@ -1858,7 +1858,7 @@ proc expandTilde*(path: string): string =
## The behaviour of this proc is the same on the Windows platform despite not ## The behaviour of this proc is the same on the Windows platform despite not
## having this convention. Example: ## having this convention. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## let configFile = expandTilde("~" / "appname.cfg") ## let configFile = expandTilde("~" / "appname.cfg")
## echo configFile ## echo configFile
## # --> C:\Users\amber\appname.cfg ## # --> C:\Users\amber\appname.cfg
@ -1889,7 +1889,7 @@ type
creationTime*: Time # Time file was created. Not supported on all systems! creationTime*: Time # Time file was created. Not supported on all systems!
template rawToFormalFileInfo(rawInfo, formalInfo): expr = template rawToFormalFileInfo(rawInfo, formalInfo): expr =
## Transforms the native file info structure into the one nimrod uses. ## Transforms the native file info structure into the one nim uses.
## 'rawInfo' is either a 'TBY_HANDLE_FILE_INFORMATION' structure on Windows, ## 'rawInfo' is either a 'TBY_HANDLE_FILE_INFORMATION' structure on Windows,
## or a 'TStat' structure on posix ## or a 'TStat' structure on posix
when defined(Windows): when defined(Windows):

View file

@ -771,7 +771,7 @@ elif not defined(useNimRtl):
proc startProcessAfterFork(data: ptr TStartProcessData) = proc startProcessAfterFork(data: ptr TStartProcessData) =
# Warning: no GC here! # Warning: no GC here!
# Or anything that touches global structures - all called nimrod procs # Or anything that touches global structures - all called nim procs
# must be marked with stackTrace:off. Inspect C code after making changes. # must be marked with stackTrace:off. Inspect C code after making changes.
if not data.optionPoParentStreams: if not data.optionPoParentStreams:
discard close(data.pStdin[writeIdx]) discard close(data.pStdin[writeIdx])

View file

@ -132,7 +132,7 @@ when declared(initOptParser):
## This is an convenience iterator for iterating over the command line. ## This is an convenience iterator for iterating over the command line.
## This uses the TOptParser object. Example: ## This uses the TOptParser object. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var ## var
## filename = "" ## filename = ""
## for kind, key, val in getopt(): ## for kind, key, val in getopt():

View file

@ -348,13 +348,13 @@ iterator interpolatedFragments*(s: string): tuple[kind: InterpolatedKind,
## ##
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## for k, v in interpolatedFragments(" $this is ${an example} $$"): ## for k, v in interpolatedFragments(" $this is ${an example} $$"):
## echo "(", k, ", \"", v, "\")" ## echo "(", k, ", \"", v, "\")"
## ##
## Results in: ## Results in:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## (ikString, " ") ## (ikString, " ")
## (ikExpr, "this") ## (ikExpr, "this")
## (ikString, " is ") ## (ikString, " is ")

View file

@ -33,7 +33,7 @@
## XML parser to accomplish a simple task: To determine the title of an HTML ## XML parser to accomplish a simple task: To determine the title of an HTML
## document. ## document.
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## :file: examples/htmltitle.nim ## :file: examples/htmltitle.nim
## ##
## ##
@ -44,7 +44,7 @@
## XML parser to accomplish another simple task: To determine all the links ## XML parser to accomplish another simple task: To determine all the links
## an HTML document contains. ## an HTML document contains.
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## :file: examples/htmlrefs.nim ## :file: examples/htmlrefs.nim
## ##

View file

@ -298,7 +298,7 @@ when not defined(JS):
## To generate useful timing values, take the difference between ## To generate useful timing values, take the difference between
## the results of two ``cpuTime`` calls: ## the results of two ``cpuTime`` calls:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var t0 = cpuTime() ## var t0 = cpuTime()
## doWork() ## doWork()
## echo "CPU time [s] ", cpuTime() - t0 ## echo "CPU time [s] ", cpuTime() - t0

View file

@ -275,12 +275,12 @@ proc xmlConstructor(e: PNimrodNode): PNimrodNode {.compileTime.} =
macro `<>`*(x: expr): expr {.immediate.} = macro `<>`*(x: expr): expr {.immediate.} =
## Constructor macro for XML. Example usage: ## Constructor macro for XML. Example usage:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## <>a(href="http://nimrod-code.org", newText("Nim rules.")) ## <>a(href="http://nim-code.org", newText("Nim rules."))
## ##
## Produces an XML tree for:: ## Produces an XML tree for::
## ##
## <a href="http://nimrod-code.org">Nim rules.</a> ## <a href="http://nim-code.org">Nim rules.</a>
## ##
let x = callsite() let x = callsite()
result = xmlConstructor(x) result = xmlConstructor(x)
@ -339,5 +339,5 @@ proc findAll*(n: XmlNode, tag: string): seq[XmlNode] =
findAll(n, tag, result) findAll(n, tag, result)
when isMainModule: when isMainModule:
assert """<a href="http://nimrod-code.org">Nim rules.</a>""" == assert """<a href="http://nim-code.org">Nim rules.</a>""" ==
$(<>a(href="http://nimrod-code.org", newText("Nim rules."))) $(<>a(href="http://nim-code.org", newText("Nim rules.")))

View file

@ -100,7 +100,7 @@ proc defined*(x: expr): bool {.magic: "Defined", noSideEffect.}
## Special compile-time procedure that checks whether `x` is ## Special compile-time procedure that checks whether `x` is
## defined. ## defined.
## `x` is an external symbol introduced through the compiler's ## `x` is an external symbol introduced through the compiler's
## `-d:x switch <nimrodc.html#compile-time-symbols>`_ to enable build time ## `-d:x switch <nimc.html#compile-time-symbols>`_ to enable build time
## conditionals: ## conditionals:
## ##
## .. code-block:: Nim ## .. code-block:: Nim
@ -509,7 +509,7 @@ proc sizeof*[T](x: T): Natural {.magic: "SizeOf", noSideEffect.}
proc `<`*[T](x: Ordinal[T]): T {.magic: "UnaryLt", noSideEffect.} proc `<`*[T](x: Ordinal[T]): T {.magic: "UnaryLt", noSideEffect.}
## unary ``<`` that can be used for nice looking excluding ranges: ## unary ``<`` that can be used for nice looking excluding ranges:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## for i in 0 .. <10: echo i ## for i in 0 .. <10: echo i
## ##
## Semantically this is the same as ``pred``. ## Semantically this is the same as ``pred``.
@ -544,7 +544,7 @@ proc newSeq*[T](s: var seq[T], len: int) {.magic: "NewSeq", noSideEffect.}
## ``nil``. After the creation of the sequence you should assign entries to ## ``nil``. After the creation of the sequence you should assign entries to
## the sequence instead of adding them. Example: ## the sequence instead of adding them. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var inputStrings : seq[string] ## var inputStrings : seq[string]
## newSeq(inputStrings, 3) ## newSeq(inputStrings, 3)
## inputStrings[0] = "The fourth" ## inputStrings[0] = "The fourth"
@ -560,7 +560,7 @@ proc newSeq*[T](len = 0): seq[T] =
## ``nil``. After the creation of the sequence you should assign entries to ## ``nil``. After the creation of the sequence you should assign entries to
## the sequence instead of adding them. Example: ## the sequence instead of adding them. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var inputStrings = newSeq[string](3) ## var inputStrings = newSeq[string](3)
## inputStrings[0] = "The fourth" ## inputStrings[0] = "The fourth"
## inputStrings[1] = "assignment" ## inputStrings[1] = "assignment"
@ -1058,7 +1058,7 @@ proc compileOption*(option: string): bool {.
magic: "CompileOption", noSideEffect.} magic: "CompileOption", noSideEffect.}
## can be used to determine an on|off compile-time option. Example: ## can be used to determine an on|off compile-time option. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## when compileOption("floatchecks"): ## when compileOption("floatchecks"):
## echo "compiled with floating point NaN and Inf checks" ## echo "compiled with floating point NaN and Inf checks"
@ -1066,7 +1066,7 @@ proc compileOption*(option, arg: string): bool {.
magic: "CompileOptionArg", noSideEffect.} magic: "CompileOptionArg", noSideEffect.}
## can be used to determine an enum compile-time option. Example: ## can be used to determine an enum compile-time option. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## when compileOption("opt", "size") and compileOption("gc", "boehm"): ## when compileOption("opt", "size") and compileOption("gc", "boehm"):
## echo "compiled with optimization for size and uses Boehm's GC" ## echo "compiled with optimization for size and uses Boehm's GC"
@ -1123,7 +1123,7 @@ proc quit*(errorcode: int = QuitSuccess) {.
## procedures. It does *not* call the garbage collector to free all the ## procedures. It does *not* call the garbage collector to free all the
## memory, unless a quit procedure calls ``GC_collect``. ## memory, unless a quit procedure calls ``GC_collect``.
## ##
## The proc ``quit(QuitSuccess)`` is called implicitly when your nimrod ## The proc ``quit(QuitSuccess)`` is called implicitly when your nim
## program finishes without incident. A raised unhandled exception is ## program finishes without incident. A raised unhandled exception is
## equivalent to calling ``quit(QuitFailure)``. ## equivalent to calling ``quit(QuitFailure)``.
## ##
@ -1840,7 +1840,7 @@ proc map*[T, S](data: openArray[T], op: proc (x: T): S {.closure.}): seq[S] =
## Since the input is not modified you can use this version of ``map`` to ## Since the input is not modified you can use this version of ``map`` to
## transform the type of the elements in the input sequence. Example: ## transform the type of the elements in the input sequence. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## let ## let
## a = @[1, 2, 3, 4] ## a = @[1, 2, 3, 4]
## b = map(a, proc(x: int): string = $x) ## b = map(a, proc(x: int): string = $x)
@ -1854,7 +1854,7 @@ proc map*[T](data: var openArray[T], op: proc (x: var T) {.closure.}) =
## Note that this version of ``map`` requires your input and output types to ## Note that this version of ``map`` requires your input and output types to
## be the same, since they are modified in-place. Example: ## be the same, since they are modified in-place. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var a = @["1", "2", "3", "4"] ## var a = @["1", "2", "3", "4"]
## echo repr(a) ## echo repr(a)
## # --> ["1", "2", "3", "4"] ## # --> ["1", "2", "3", "4"]
@ -1945,7 +1945,7 @@ proc `$`*[T: tuple|object](x: T): string =
## generic ``$`` operator for tuples that is lifted from the components ## generic ``$`` operator for tuples that is lifted from the components
## of `x`. Example: ## of `x`. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## $(23, 45) == "(23, 45)" ## $(23, 45) == "(23, 45)"
## $() == "()" ## $() == "()"
result = "(" result = "("
@ -1971,7 +1971,7 @@ proc `$`*[T](x: set[T]): string =
## generic ``$`` operator for sets that is lifted from the components ## generic ``$`` operator for sets that is lifted from the components
## of `x`. Example: ## of `x`. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ${23, 45} == "{23, 45}" ## ${23, 45} == "{23, 45}"
collectionToString(x, "{", "}") collectionToString(x, "{", "}")
@ -1979,7 +1979,7 @@ proc `$`*[T](x: seq[T]): string =
## generic ``$`` operator for seqs that is lifted from the components ## generic ``$`` operator for seqs that is lifted from the components
## of `x`. Example: ## of `x`. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## $(@[23, 45]) == "@[23, 45]" ## $(@[23, 45]) == "@[23, 45]"
collectionToString(x, "@[", "]") collectionToString(x, "@[", "]")
@ -2078,7 +2078,7 @@ var
## writes an error message and terminates the program. `outOfMemHook` can ## writes an error message and terminates the program. `outOfMemHook` can
## be used to raise an exception in case of OOM like so: ## be used to raise an exception in case of OOM like so:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## var gOutOfMem: ref EOutOfMemory ## var gOutOfMem: ref EOutOfMemory
## new(gOutOfMem) # need to be allocated *before* OOM really happened! ## new(gOutOfMem) # need to be allocated *before* OOM really happened!
@ -2576,7 +2576,7 @@ when not defined(JS): #and not defined(NimrodVM):
## If the file does not exist `EIO` is raised. The trailing newline ## If the file does not exist `EIO` is raised. The trailing newline
## character(s) are removed from the iterated lines. Example: ## character(s) are removed from the iterated lines. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## import strutils ## import strutils
## ##
## proc transformLetters(filename: string) = ## proc transformLetters(filename: string) =
@ -2595,7 +2595,7 @@ when not defined(JS): #and not defined(NimrodVM):
## The trailing newline character(s) are removed from the iterated lines. ## The trailing newline character(s) are removed from the iterated lines.
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## proc countZeros(filename: File): tuple[lines, zeros: int] = ## proc countZeros(filename: File): tuple[lines, zeros: int] =
## for line in filename.lines: ## for line in filename.lines:
## for letter in line: ## for letter in line:
@ -2645,7 +2645,7 @@ when not defined(JS): #and not defined(NimrodVM):
## platforms this can help the processor predict better which branch is ## platforms this can help the processor predict better which branch is
## going to be run. Example: ## going to be run. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## for value in inputValues: ## for value in inputValues:
## if likely(value <= 100): ## if likely(value <= 100):
## process(value) ## process(value)
@ -2659,7 +2659,7 @@ when not defined(JS): #and not defined(NimrodVM):
## platforms this can help the processor predict better which branch is ## platforms this can help the processor predict better which branch is
## going to be run. Example: ## going to be run. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## for value in inputValues: ## for value in inputValues:
## if unlikely(value > 100): ## if unlikely(value > 100):
## echo "Value too big!" ## echo "Value too big!"
@ -2766,7 +2766,7 @@ when hostOS != "standalone":
## ``b.len`` is not exactly the number of elements that are referred to ## ``b.len`` is not exactly the number of elements that are referred to
## by `x`, a `splice`:idx: is performed: ## by `x`, a `splice`:idx: is performed:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## var s = "abcdef" ## var s = "abcdef"
## s[1 .. -2] = "xyz" ## s[1 .. -2] = "xyz"
## assert s == "axyzf" ## assert s == "axyzf"
@ -2843,7 +2843,7 @@ proc slurp*(filename: string): string {.magic: "Slurp".}
proc staticRead*(filename: string): string {.magic: "Slurp".} proc staticRead*(filename: string): string {.magic: "Slurp".}
## Compile-time ``readFile`` proc for easy `resource`:idx: embedding: ## Compile-time ``readFile`` proc for easy `resource`:idx: embedding:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## const myResource = staticRead"mydatafile.bin" ## const myResource = staticRead"mydatafile.bin"
## ##
## ``slurp`` is an alias for ``staticRead``. ## ``slurp`` is an alias for ``staticRead``.
@ -2858,13 +2858,13 @@ proc staticExec*(command: string, input = ""): string {.
## if `input` is not an empty string, it will be passed as a standard input ## if `input` is not an empty string, it will be passed as a standard input
## to the executed program. ## to the executed program.
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## const buildInfo = "Revision " & staticExec("git rev-parse HEAD") & ## const buildInfo = "Revision " & staticExec("git rev-parse HEAD") &
## "\nCompiled on " & staticExec("uname -v") ## "\nCompiled on " & staticExec("uname -v")
## ##
## ``gorge`` is an alias for ``staticExec``. Note that you can use this proc ## ``gorge`` is an alias for ``staticExec``. Note that you can use this proc
## inside a pragma like `passC <nimrodc.html#passc-pragma>`_ or `passL ## inside a pragma like `passC <nimc.html#passc-pragma>`_ or `passL
## <nimrodc.html#passl-pragma>`_. ## <nimc.html#passl-pragma>`_.
proc `+=`*[T: SomeOrdinal|uint|uint64](x: var T, y: T) {.magic: "Inc", noSideEffect.} proc `+=`*[T: SomeOrdinal|uint|uint64](x: var T, y: T) {.magic: "Inc", noSideEffect.}
## Increments an ordinal ## Increments an ordinal
@ -2906,7 +2906,7 @@ proc instantiationInfo*(index = -1, fullPaths = false): tuple[
## to retrieve information about the current filename and line number. ## to retrieve information about the current filename and line number.
## Example: ## Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## import strutils ## import strutils
## ##
## template testException(exception, code: expr): stmt = ## template testException(exception, code: expr): stmt =
@ -2951,7 +2951,7 @@ template assert*(cond: bool, msg = "") =
## raises an ``EAssertionFailure`` exception. However, the compiler may not ## raises an ``EAssertionFailure`` exception. However, the compiler may not
## generate any code at all for ``assert`` if it is advised to do so through ## generate any code at all for ``assert`` if it is advised to do so through
## the ``-d:release`` or ``--assertions:off`` `command line switches ## the ``-d:release`` or ``--assertions:off`` `command line switches
## <nimrodc.html#command-line-switches>`_. ## <nimc.html#command-line-switches>`_.
## ##
## Use ``assert`` for debugging purposes only. ## Use ``assert`` for debugging purposes only.
bind instantiationInfo bind instantiationInfo
@ -2994,7 +2994,7 @@ template onFailedAssert*(msg: expr, code: stmt): stmt {.dirty, immediate.} =
## statements following `onFailedAssert` in the current lexical scope. ## statements following `onFailedAssert` in the current lexical scope.
## Can be defined multiple times in a single function. ## Can be defined multiple times in a single function.
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## ##
## proc example(x: int): TErrorCode = ## proc example(x: int): TErrorCode =
## onFailedAssert(msg): ## onFailedAssert(msg):
@ -3089,7 +3089,7 @@ proc locals*(): RootObj {.magic: "Locals", noSideEffect.} =
## the official signature says, the return type is not ``TObject`` but a ## the official signature says, the return type is not ``TObject`` but a
## tuple of a structure that depends on the current scope. Example: ## tuple of a structure that depends on the current scope. Example:
## ##
## .. code-block:: nimrod ## .. code-block:: nim
## proc testLocals() = ## proc testLocals() =
## var ## var
## a = "something" ## a = "something"