Open chris-martin opened 6 years ago
We should rename Param
to Pattern
while we're at it, and explain in the documentation that a single-variable binding is just a simple special case of a pattern.
Patterns would be strictly more general than the inherit
style of let
binding.
let { a, b, ... } = c; in d
would be equivalent to let inherit (c) a b; in d
But these expressions have no direct analog in Nix:
let { a, b ? e, ... } = c; in d
let { a, b } = c; in d
I'm not sure now whether inherit
should be allowed for let
bindings. I'd like to remove it for simplicity. However, it does have an appealing symmetry with inherit
in dict literals. So that also raises the question, then, of whether the dict version of inherit
can also be obviated in some way. I don't see any good way to do that, though, without introducing a reliance on standard library functions for common use cases. At the moment I am inclined to keep let
-inherit
around, for the sake of the appealing symmetry.
On second thought, dict bindings that inherit from another dict could work just the same way.
bricks-repl> let x = { a = "1"; b = "2"; c = "3"; }; in { { a, b, ... } = x; }
{ a = "1"; b = "2"; }
This seems rather equivalent to putting them in lambda parameters, and I don't think introduces any syntactic ambiguity, so I see no reason not to add this.