1
0
Fork 0
mirror of https://github.com/NixOS/nix.dev.git synced 2024-10-18 14:32:43 -04:00

remove description of language properties

this should be in the Nix manual
This commit is contained in:
Valentin Gagarin 2022-08-15 11:58:34 +02:00
parent c0b0c2ba32
commit c7729502bc

View file

@ -766,62 +766,4 @@ The `meta` attribute is itself an attribute set, where the `license` attribute h
(This example is a (simplified) package declaration from `nixpkgs`.)
# Nix language properties
As a programming language, Nix is
- *declarative*
It has no notion of executing sequential steps.
Dependencies between operations are established only through data.
- *purely functional*
Pure means: Nix does not change the value of declarations during computation there are no actual variables, only names for immutable values.
Functional means: In Nix, functions are like any other value.
Functions can be assigned to names, taken as arguments, or returned by functions.
- *lazy*
It will only evaluate expressions when their result is needed.[^4]
- *dynamically typed*
Type errors are only detected when expressions are actually evaluated.[^5]
- *purpose-built*
The Nix language only exists for the Nix package manager.
It is not intended for general purpose use.
[^4]: For example, the built-in function `throw` causes evaluation to stop. However, the following works, because `throw` is never evaluated:
```nix
let lazy = { a = "success"; b = builtins.throw "error"; }; in lazy.a
```
"success"
[^5]: For example, while one cannot add integers to strings, the error is not detected by simply parsing the meaningless expression.
```nix
let x = { a = 1 + "1"; b = 2; }; in x.b
```
2
The error only detected on evaluation, that is, when trying to access the result.
```nix
let x = { a = 1 + "1"; b = 2; }; in x.a
```
error: cannot add a string to an integer
at «string»:1:19:
1| let x = { a = 1 + "1"; b = 2; }; in x.a
| ^
2|