mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-25 16:53:59 +00:00
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:
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## This module is a sample.
|
||||
|
||||
import strutils
|
||||
import std/strutils
|
||||
|
||||
proc helloWorld*(times: int) =
|
||||
## Takes an integer and outputs
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user