> It's not sets... It's attrsets
You may want to tell, er, the official website? https://nixos.org/manual/nix/stable/language/index.html
> { x = 1; y = 2; } A set with attributes named x and y
> and the naming of the construct doesn't matter.
It absolutely matters when you're trying to learn the language and the naming of concepts is nonsensical.
> Pattern syntax and construction syntax are different in every functional language I know.
So you don't know Haskell?
-- construction
example = Person { name = "John Doe", admin = True }
-- pattern
render Person { name = name, admin = admin } = name ++ suffix
where
suffix = if admin then " - Admin" else ""
or OCaml?
(* construction *)
let initial_state = { lcd=0; lka=Equals; loa=Equals; vpr=0 } ;;
(* pattern *)
match s with
| { lcd = a; vpr = d; _ } -> (* Expression *)
or Rust?
// construction
let p = Point { x: 0, y: 7 };
// pattern
let Point { x: a, y: b } = p;
All three have punning (as an extension for Haskell) so you can skip the explicit rebinding, but that's not what Nix does, as far as I can tell it doesn't have punning on the construction side, doesn't have full syntax on the pattern side, and the syntaxes are
just similar enough to be annoying:
# construction
{ x = 1; y = 2; }
# pattern
{ x, y }: x + y
> You're thinking of XQuery I think
No, I am not.
> I honestly don't understand what is surprising about the nix language.
I can only assume that's Stockholm syndrome given I literally just went through https://nixos.org/manual/nix/stable/language/index.html and found the inconsistencies listed above, also that @ patterns can go on either side (why?), or the existence of "with" (though I guess in a functional and pure language it's not as bad as it is in good ol javascript with which it shares this great feature).
And it's not that it's "surprising", it's just that it's... sloppy. Sub-par.
And definitely not "intuitive". Even less so when a pair of single quotes is equivalent to a double quote (except not), rather than either an empty string (or at least something string-like), or an error. To say nothing of the escaping scheme inside those string literals.