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

complete std prefixes for stdlib #22887

Merged
merged 2 commits into from
Oct 30, 2023
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
12 changes: 6 additions & 6 deletions doc/astspec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -907,7 +907,7 @@ With ``except``, we get ``nnkImportExceptStmt``.
Concrete syntax:

```nim
import math except pow
import std/math except pow
```

AST:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/docgen_sample.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## This module is a sample.

import strutils
import std/strutils

proc helloWorld*(times: int) =
## Takes an integer and outputs
Expand Down
2 changes: 1 addition & 1 deletion doc/estp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/manual_experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/core/hotcodereloading.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

when defined(hotcodereloading):
import
macros
std/macros

template beforeCodeReload*(body: untyped) =
hcrAddEventHandler(true, proc = body) {.executeOnReload.}
Expand Down
2 changes: 1 addition & 1 deletion lib/deprecated/pure/future.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

{.deprecated: "Use the new 'sugar' module instead".}

import sugar
import std/sugar
export sugar
2 changes: 1 addition & 1 deletion lib/deprecated/pure/ospaths.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

{.deprecated: "use `std/os` instead".}

import os
import std/os
export ReadEnvEffect, WriteEnvEffect, ReadDirEffect, WriteDirEffect, OSErrorCode,
doslikeFileSystem, CurDir, ParDir, DirSep, AltSep, PathSep, FileSystemCaseSensitive,
ExeExt, ScriptExt, DynlibFormat, ExtSep, joinPath, `/`, splitPath, parentDir,
Expand Down
6 changes: 3 additions & 3 deletions lib/deprecated/pure/oswalkdir.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#

## This module is deprecated, `import os` instead.
{.deprecated: "import os.nim instead".}
import os
## This module is deprecated, `import std/os` instead.
{.deprecated: "import 'std/os' instead".}
import std/os
export PathComponent, walkDir, walkDirRec
2 changes: 1 addition & 1 deletion lib/experimental/diff.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jkl"""
# "An O(ND) Difference Algorithm and its Variations" by Eugene Myers
# Algorithmica Vol. 1 No. 2, 1986, p 251.

import tables, strutils
import std/[tables, strutils]

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down
10 changes: 5 additions & 5 deletions lib/impure/nre.nim
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ runnableExamples:
assert find("uxabc", re"(?<=x|y)ab", start = 1).get.captures[-1] == "ab"
assert find("uxabc", re"ab", start = 3).isNone

from pcre import nil
from std/pcre import nil
import nre/private/util
import tables
from strutils import `%`
import options
from unicode import runeLenAt
import std/tables
from std/strutils import `%`
import std/options
from std/unicode import runeLenAt

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down
2 changes: 1 addition & 1 deletion lib/impure/nre/private/util.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## INTERNAL FILE FOR USE ONLY BY nre.nim.
import tables
import std/tables

const Ident = {'a'..'z', 'A'..'Z', '0'..'9', '_', '\128'..'\255'}
const StartIdent = Ident - {'0'..'9'}
Expand Down
2 changes: 1 addition & 1 deletion lib/impure/rdstdin.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ elif defined(genode):
stdin.readLine(line)

else:
import linenoise
import std/linenoise

proc readLineFromStdin*(prompt: string, line: var string): bool {.
tags: [ReadIOEffect, WriteIOEffect].} =
Expand Down
2 changes: 1 addition & 1 deletion lib/impure/re.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runnableExamples:
# can't match start of string since we're starting at 1

import
pcre, strutils, rtarrays
std/[pcre, strutils, rtarrays]

when defined(nimPreviewSlimSystem):
import std/syncio
Expand Down
2 changes: 1 addition & 1 deletion lib/nimhcr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ when defined(createNimHcr):
when system.appType != "lib":
{.error: "This file has to be compiled as a library!".}

import os, tables, sets, times, strutils, reservedmem, dynlib
import std/[os, tables, sets, times, strutils, reservedmem, dynlib]

template trace(args: varargs[untyped]) =
when defined(testNimHcr) or defined(traceHcr):
Expand Down
4 changes: 2 additions & 2 deletions lib/nimrtl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ when not defined(createNimRtl):
{.error: "This file has to be compiled with '-d:createNimRtl'".}

import
parseutils, strutils, parseopt, parsecfg, strtabs, unicode, pegs, ropes,
os, osproc, times, cstrutils
std/[parseutils, strutils, parseopt, parsecfg, strtabs, unicode, pegs, ropes,
os, osproc, times, cstrutils]
3 changes: 2 additions & 1 deletion lib/packages/docutils/dochelpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
## `type LangSymbol`_ in ``rst.nim``, while `match(generated, docLink)`_
## matches it with `generated`, produced from `PNode` by ``docgen.rst``.

import rstast, strutils
import rstast
import std/strutils

when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
Expand Down
4 changes: 2 additions & 2 deletions lib/packages/docutils/highlite.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
## as program output.

import
strutils
from algorithm import binarySearch
std/strutils
from std/algorithm import binarySearch

when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
Expand Down
6 changes: 4 additions & 2 deletions lib/packages/docutils/rst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
## turned on by passing ``options:`` [RstParseOptions] to [proc rstParse].

import
os, strutils, rstast, dochelpers, std/enumutils, algorithm, lists, sequtils,
std/private/miscdollars, tables, strscans, rstidx
std/[os, strutils, enumutils, algorithm, lists, sequtils,
tables, strscans]
import dochelpers, rstidx, rstast
import std/private/miscdollars
from highlite import SourceLanguage, getSourceLanguage

when defined(nimPreviewSlimSystem):
Expand Down
2 changes: 1 addition & 1 deletion lib/packages/docutils/rstast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## This module implements an AST for the `reStructuredText`:idx: parser.

import strutils, json
import std/[strutils, json]

when defined(nimPreviewSlimSystem):
import std/assertions
Expand Down
6 changes: 3 additions & 3 deletions lib/packages/docutils/rstgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
## No backreferences are generated since finding all references of a footnote
## can be done by simply searching for ``[footnoteName]``.

import strutils, os, hashes, strtabs, rstast, rst, rstidx,
highlite, tables, sequtils,
algorithm, parseutils, std/strbasics
import std/[strutils, os, hashes, strtabs, tables, sequtils,
algorithm, parseutils, strbasics]

import rstast, rst, rstidx, highlite

when defined(nimPreviewSlimSystem):
import std/[assertions, syncio, formatfloat]
Expand Down
4 changes: 2 additions & 2 deletions lib/packages/docutils/rstidx.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

## Nim `idx`:idx: file format related definitions.

import strutils, std/syncio, hashes
from os import splitFile
import std/[strutils, syncio, hashes]
from std/os import splitFile

type
IndexEntryKind* = enum ## discriminator tag
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/epoll.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#

from posix import SocketHandle
from std/posix import SocketHandle

const
EPOLLIN* = 0x00000001
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/kqueue.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#

from posix import Timespec
from std/posix import Timespec

when defined(macosx) or defined(freebsd) or defined(openbsd) or
defined(dragonfly):
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/linux.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import posix
import std/posix

## Flags of `clone` syscall.
## See `clone syscall manual
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/posix_utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Where possible, contribute OS-independent procs in `os <os.html>`_ instead.

import posix, parsecfg, os
import std/[posix, parsecfg, os]
import std/private/since

when defined(nimPreviewSlimSystem):
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/termios.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# distribution, for details about the copyright.
#

import posix
import std/posix

type
Speed* = cuint
Expand Down
4 changes: 2 additions & 2 deletions lib/pure/async.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
## and [asyncjs](asyncjs.html) on the JS backend.

when defined(js):
import asyncjs
import std/asyncjs
export asyncjs
else:
import asyncmacro, asyncfutures
import std/[asyncmacro, asyncfutures]
export asyncmacro, asyncfutures
20 changes: 10 additions & 10 deletions lib/pure/asyncdispatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@
## ``none`` can be used when a library supports both a synchronous and
## asynchronous API, to disable the latter.

import os, tables, strutils, times, heapqueue, options, asyncstreams
import options, math, std/monotimes
import asyncfutures except callSoon
import std/[os, tables, strutils, times, heapqueue, options, asyncstreams]
import std/[math, monotimes]
import std/asyncfutures except callSoon

import nativesockets, net, deques
import std/[nativesockets, net, deques]

when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
Expand Down Expand Up @@ -302,7 +302,7 @@ template implementSetInheritable() {.dirty.} =
fd.FileHandle.setInheritable(inheritable)

when defined(windows) or defined(nimdoc):
import winlean, sets, hashes
import std/[winlean, sets, hashes]
type
CompletionKey = ULONG_PTR

Expand Down Expand Up @@ -1166,11 +1166,11 @@ when defined(windows) or defined(nimdoc):

initAll()
else:
import selectors
from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
import std/selectors
from std/posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
MSG_NOSIGNAL
when declared(posix.accept4):
from posix import accept4, SOCK_CLOEXEC
from std/posix import accept4, SOCK_CLOEXEC
when defined(genode):
import genode/env # get the implicit Genode env
import genode/signals
Expand Down Expand Up @@ -1994,7 +1994,7 @@ proc send*(socket: AsyncFD, data: string,
return retFuture

# -- Await Macro
import asyncmacro
import std/asyncmacro
export asyncmacro

proc readAll*(future: FutureStream[string]): owned(Future[string]) {.async.} =
Expand Down Expand Up @@ -2032,7 +2032,7 @@ proc activeDescriptors*(): int {.inline.} =
result = getGlobalDispatcher().selector.count

when defined(posix):
import posix
import std/posix

when defined(linux) or defined(windows) or defined(macosx) or defined(bsd) or
defined(solaris) or defined(zephyr) or defined(freertos) or defined(nuttx) or defined(haiku):
Expand Down
Loading
Loading