complete std prefixes for stdlib (#22887)

follow up https://github.com/nim-lang/Nim/pull/22851
follow up https://github.com/nim-lang/Nim/pull/22873
This commit is contained in:
ringabout
2023-10-31 00:03:04 +08:00
committed by GitHub
parent 403e0118ae
commit 4d11d0619d
142 changed files with 277 additions and 275 deletions

View File

@@ -893,7 +893,7 @@ on what keywords are present. Let's start with the simplest form.
Concrete syntax:
```nim
import math
import std/math
```
AST:
@@ -907,7 +907,7 @@ With ``except``, we get ``nnkImportExceptStmt``.
Concrete syntax:
```nim
import math except pow
import std/math except pow
```
AST:
@@ -916,13 +916,13 @@ AST:
nnkImportExceptStmt(nnkIdent("math"),nnkIdent("pow"))
```
Note that ``import math as m`` does not use a different node; rather,
Note that ``import std/math as m`` does not use a different node; rather,
we use ``nnkImportStmt`` with ``as`` as an infix operator.
Concrete syntax:
```nim
import strutils as su
import std/strutils as su
```
AST:
@@ -945,7 +945,7 @@ If we use ``from ... import``, the result is different, too.
Concrete syntax:
```nim
from math import pow
from std/math import pow
```
AST:
@@ -954,7 +954,7 @@ AST:
nnkFromStmt(nnkIdent("math"), nnkIdent("pow"))
```
Using ``from math as m import pow`` works identically to the ``as`` modifier
Using ``from std/math as m import pow`` works identically to the ``as`` modifier
with the ``import`` statement, but wrapped in ``nnkFromStmt``.
Export statement

View File

@@ -1,6 +1,6 @@
## This module is a sample.
import strutils
import std/strutils
proc helloWorld*(times: int) =
## Takes an integer and outputs

View File

@@ -28,7 +28,7 @@ Otherwise your program is profiled.
```nim
when compileOption("profiler"):
import nimprof
import std/nimprof
```
After your program has finished the profiler will create a

View File

@@ -655,7 +655,7 @@ string containing the literal. The callable identifier needs to be declared
with a special ``'`` prefix:
```nim
import strutils
import std/strutils
type u4 = distinct uint8 # a 4-bit unsigned integer aka "nibble"
proc `'u4`(n: string): u4 =
# The leading ' is required.
@@ -670,7 +670,7 @@ corresponds to this transformation. The transformation naturally handles
the case that additional parameters are passed to the callee:
```nim
import strutils
import std/strutils
type u4 = distinct uint8 # a 4-bit unsigned integer aka "nibble"
proc `'u4`(n: string; moreData: int): u4 =
result = (parseInt(n) and 0x0F).u4
@@ -5231,7 +5231,7 @@ conservative in its effect analysis:
```nim test = "nim c $1" status = 1
{.push warningAsError[Effect]: on.}
import algorithm
import std/algorithm
type
MyInt = distinct int

View File

@@ -1368,7 +1368,7 @@ to be computed dynamically.
```nim
{.experimental: "dynamicBindSym".}
import macros
import std/macros
macro callOp(opName, arg1, arg2): untyped =
result = newCall(bindSym($opName), arg1, arg2)