Lix is an independent variant of the Nix package manager, developed by a team of open-source volunteers, and maintained by and for a passionate community of users.
Nix being an expression based functional language, it doesn’t really make sense to have something like let x=y; since this looks to most people like a statement (i.e. a line of code that gets executed as part of a sequence). This doesn’t exist in nix—instead you have expressions that get lazily evaluated, possibly out of order compared to what you’d expect. let x=y in makes it more clear that the variable binding you’re doing is only in scope for the current expression, which reads something like “let x refer to y in x + 3”
The function definition syntax is unusual but definitely not unintuitive imo. It captures the simplicity of the function semantics of nix—a function is just a mapping/transformation from one value (or set of values) to another. I don’t think it’s too much overhead to learn that they use : to mean this instead of =>
In terms of why they picked this syntax, it follows the traditions of other functional languages such as the ML family, Haskell etc.
Nix being an expression based functional language, it doesn’t really make sense to have something like let x=y; since this looks to most people like a statement
I know of several languages that just have let x=y; <expr> as an expression. It works fine, it’s just more obvious syntax.
The fact that it looks like a statement is kind of the point.
it follows the traditions of other functional languages such as the ML
OCaml at least supports both forms. They didn’t have to pick the weird one.
Nix being an expression based functional language, it doesn’t really make sense to have something like
let x=y;
since this looks to most people like a statement (i.e. a line of code that gets executed as part of a sequence). This doesn’t exist in nix—instead you have expressions that get lazily evaluated, possibly out of order compared to what you’d expect.let x=y in
makes it more clear that the variable binding you’re doing is only in scope for the current expression, which reads something like “let x refer to y in x + 3”The function definition syntax is unusual but definitely not unintuitive imo. It captures the simplicity of the function semantics of nix—a function is just a mapping/transformation from one value (or set of values) to another. I don’t think it’s too much overhead to learn that they use
:
to mean this instead of=>
In terms of why they picked this syntax, it follows the traditions of other functional languages such as the ML family, Haskell etc.
I know of several languages that just have
let x=y; <expr>
as an expression. It works fine, it’s just more obvious syntax.The fact that it looks like a statement is kind of the point.
OCaml at least supports both forms. They didn’t have to pick the weird one.