add example of best effort interop

This commit is contained in:
Valentin Gagarin 2023-06-15 14:39:46 +02:00 committed by GitHub
parent 76a3d1fe01
commit f193f543ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -564,6 +564,30 @@ $ nix-instantiate --eval bnix
error: unsupported value type `complex` at built-in operator `+` error: unsupported value type `complex` at built-in operator `+`
``` ```
In the following example, version 7 *removed* the `null` primitive, such that it can no longer be used.
```nix
# a.nix
null
```
```nix
# b.nix
version 7;
import ./a.nix
```
```console
$ nix-instantiate --eval b.nix
error: unsupported value `null`
```
This is consistent with best-effort interoperability:
Old code keeps working on its own, and new code has to be adapted because it was not there before the breaking change.
While this requires additional effort to adopt the new language version, expression authors can always recourse to writing new code in older versions while using newer evaluators.
This in fact allows for creating compatibility wrappers as needed.
## Deprecation warnings ## Deprecation warnings
``` ```