You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rfcs/0137-nix-language-version.md
+51-3
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,10 @@ Other discussions around language changes:
133
133
134
134
1. The language version for Nix expressions is denoted in special syntax, at the beginning of a parse unit.
135
135
A parse unit is any text stream, e.g. a file or string.
136
+
The evaluator must ignore a shebang line (starting with `#!) at the start of files, to leave room for additional tooling.
137
+
138
+
The language version declaration is optional if it is instead made in an external per-project file.
139
+
The details of the per-project file syntax are out of scope for this proposal.
136
140
137
141
<details><summary>Arguments</summary>
138
142
@@ -144,6 +148,7 @@ Other discussions around language changes:
144
148
- This has the same trade-offs as when introducing the new syntax to begin with
145
149
- (-) Editor support is made harder, since it requires switching the language based on file contents
146
150
- (+) Making the language version accessible at all will probably outweigh the costs
151
+
- (+) Using a per-project file avoids littering every file with version declarations.
147
152
148
153
</details>
149
154
@@ -228,7 +233,6 @@ Other discussions around language changes:
228
233
version \d*.\d*;
229
234
```
230
235
231
-
The evaluator must ignore a shebang line (starting with `#!) at the start of files, to leave room for additional tooling.
232
236
This implies that if no language version is specified in a Nix file, it is written in version 6 (the version implemented in the stable release of Nix at the time of writing this RFC).
233
237
234
238
The syntax is open for bikeshedding.
@@ -285,6 +289,10 @@ Other discussions around language changes:
285
289
286
290
Examples include semantic changes or removal of `builtins`, operators, or syntactic constructs.
287
291
292
+
Values are decidedly not covered by versioning, but must instead stay the same indefinitely.
293
+
In particular, there must not be, e.g., string values internally tagged with different language versions.
294
+
This constraint can be loosened with a follow-up RFC.
295
+
288
296
<details><summary>Arguments</summary>
289
297
290
298
- (+) The principled solution: guarantees reproducibility given a fixed language version
@@ -317,11 +325,20 @@ Other discussions around language changes:
317
325
</details>
318
326
319
327
1. Semantics are preserved across file boundaries for past language versions.
328
+
In other words, code written in an old language version evaluates to the same result when used from the new versions for all input values which are legal on the old version.
320
329
321
-
This should be fairly straightforward to implement since values passed around in the evaluator carry all the information needed to force them.
330
+
This should be fairly straightforward to implement since values passed around in the evaluator can carry all the information needed to force them.
322
331
Newer parts of the evaluator can always wrap their values in interfaces that are accepted by older parts, as far as possible.
-[Preserving semantics across version boundaries](#preserving-semantics-across-version-boundaries)
336
+
337
+
When new value types are added to the language:
338
+
339
+
- Passing new values to functions is allowed, as it cannot be prevented anyways due to laziness and composite types (like lists).
340
+
- Any values of unknown type to code from an older Nix version are treated as the opaque "external" type (which already exists for things like plugins).
341
+
Attempts at using them other than passing them around will thus cause type errors.
325
342
326
343
<details><summary>Arguments</summary>
327
344
@@ -344,6 +361,14 @@ Other discussions around language changes:
344
361
345
362
</details>
346
363
364
+
1. The backward compatibility mechanism must be "zero cost" when not used, meaning that no performance overhead must be paid when no legacy Nix files are imported.
365
+
366
+
<details><summary>Arguments</summary>
367
+
368
+
- (+) This additional implementation constraint encourages being conservative with substantial changes.
369
+
370
+
</details>
371
+
347
372
1. It is not possible to import expressions written in newer versions.
348
373
349
374
Example: [Expressions are not forward compatible](#expressions-are-not-forward-compatible)
0 commit comments