std/os/env▲toc

Access to the program environment and command line arguments.

Print the environment: get-envstd/os/env/get-env: () -> ndet env().map(fn(p) { p.fst + "=" + p.snd }).join("\n").print.

alias envstd/os/env/env: V = liststd/core/types/list: V -> V<(stringstd/core/types/string: V, stringstd/core/types/string: V)>
fun get-args(): ndetstd/core/types/ndet: X liststd/core/types/list: V -> V<stringstd/core/types/string: V>

Return the arguments that were passed to program itself. Strips off the initial program from the unprocessed command line. i.e. If a program started as:

> node myprogram.js --flag bla

The arguments list will be ["--flag","bla"].

fun get-argv(): ndetstd/core/types/ndet: X liststd/core/types/list: V -> V<stringstd/core/types/string: V>

The unprocessed command line that was used to start this program. On ‘'Node’' the first arguments will often be of the form ["node","interactive.js",...].

fun get-cc-name(): ndetstd/core/types/ndet: X stringstd/core/types/string: V

The backend compiler name, like gcc, clang, cl, clang-cl, mingw, or icc (and js for JavaScript).

fun get-compiler-version(): ndetstd/core/types/ndet: X stringstd/core/types/string: V

The current compiler version.

fun get-cpu-address-bits(): ndetstd/core/types/ndet: X intstd/core/types/int: V

Return the processor maximum address size in bits (8(*)std/core/int/(*): (int, int) -> intsizeof(vaddr_t)). This is usually equal to the get-cpu-pointer-bitsstd/os/env/get-cpu-pointer-bits: () -> ndet int but may be smaller on capability architectures like ARM CHERI.

fun get-cpu-arch(): ndetstd/core/types/ndet: X stringstd/core/types/string: V

Return the main processor architecture: x64, x86, arm64, arm32, riscv32, riscv64, alpha64, ppc64, etc.

fun get-cpu-boxed-bits(): ndetstd/core/types/ndet: X intstd/core/types/int: V

Return the size of boxed values in the heap (8(*)std/core/int/(*): (int, int) -> intsizeof(kk_box_t)). This is usually equal to 8(*)std/core/int/(*): (int, int) -> intsizeof(void*) but can be less if compressed pointers are used (when compiled with --target=c64c for example).

fun get-cpu-count(): ndetstd/core/types/ndet: X intstd/core/types/int: V

Return the available CPU's. This is the logical core count including hyper-threaded cores.

fun get-cpu-int-bits(): ndetstd/core/types/ndet: X intstd/core/types/int: V

Return the processor natural integer register size in bits.

Note: Usually this equals the get-cpu-size-bitsstd/os/env/get-cpu-size-bits: () -> ndet int and get-cpu-pointer-bitsstd/os/env/get-cpu-pointer-bits: () -> ndet int on modern cpu's but they can differ on segmented architectures. For example, on the old x86 FAR-NEAR model, the addresses are 32-bit but the integer register size is 16-bit. Or on the more recent-x32 ABI the addresses and object sizes are 32-bits but the architecture has 64-bit integer registers.

fun get-cpu-is-little-endian(): ndetstd/core/types/ndet: X boolstd/core/types/bool: V

Is the byte-order little-endian? If not, it is big-endian; other byte orders are not supported.

fun get-cpu-pointer-bits(): ndetstd/core/types/ndet: X intstd/core/types/int: V

Return the processor maximum pointer size in bits (8(*)std/core/int/(*): (int, int) -> intsizeof(void*)). This is usually equal to the get-cpu-address-bitsstd/os/env/get-cpu-address-bits: () -> ndet int but may be larger on capability architectures like ARM CHERI.

fun get-cpu-size-bits(): ndetstd/core/types/ndet: X intstd/core/types/int: V

Return the processor maximum object size in bits (8(*)std/core/int/(*): (int, int) -> intsizeof(size_t)). This is usually equal to the get-cpu-int-bitsstd/os/env/get-cpu-int-bits: () -> ndet int but may be different on segmented architectures.

fun get-env(): ndetstd/core/types/ndet: X envstd/os/env/env: V

Get the environment variables for this program.

fun get-env-value( name : stringstd/core/types/string: V ) : ndetstd/core/types/ndet: X maybestd/core/types/maybe: V -> V<stringstd/core/types/string: V>

Returns the value of an environment variable name (or Nothingstd/core/types/Nothing: forall<a> maybe<a> if not present).

fun get-os-name(): ndetstd/core/types/ndet: X stringstd/core/types/string: V

Return the main OS name: windows, linux, macos, unix, posix, ios, tvos, watchos, unknown. Sometimes has a dash subsystem, like: unix-<freebsd,openbsd,dragonfly,bsd>, and windows-mingw.

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/eitherstd/core/either, std/core/tuplestd/core/tuple, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core, std/os/pathstd/os/path