-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Can lists in Nix be infinite? #345
Comments
nix lists are not actually cons/nil linked lists under the hood, but arrays. They are strict in their length and lazy in their values. This is expected behavior. |
Ah, okay, that makes sense. As a suggestion: could we mention this in the manual? I would also suggest renaming "lists" in the manual to "arrays"; I think that captures the distinction. |
(I'd be happy to help out editing the manual, if you suggest what changes are appropriate and where.) |
Coming back to this, I'm doing some work on lazy attribute names in #4090. Once that is implemented, it will be very easy to also add support for lazy list indexing, allowing you to have infinite lists. In particular @jameshfisher's first example could work with this. |
The following expression is supposed to define the infinite list of natural numbers and evaluate to the element of that list at index 3, which should be the number
3
.Instead I get a segmentation fault:
I am assuming here that Nix lists are basically just syntactic sugar over sets; i.e. they are implemented under the hood something like this:
Is this not the case? Is the segmentation fault a bug? I didn't find the manual very clear on how exactly lists are meant to behave in this situation.
The text was updated successfully, but these errors were encountered: