Closed chris-martin closed 6 years ago
Dict
is going to need to split into Dict
and DictRec
as they are now fundamentally different constructs.
No, this is too limiting. You should be able to mix "variables" and "non-variables" in a single dict.
rec {
c = "y";
d = c;
"a b" = "x";
"${c}" = "z";
}
It is slightly awkward to describe what happens here, as not all of the keys become available as variables. Conversion from Expression
to Term
will transform this example into something like
let
c = "y";
d = c;
in {
c = c;
d = d;
"a b" = "x";
"${c}" = "z";
}
Any key that's dynamic or isn't representable in unquoted form won't get included in the recursive fun.
So I think this is fine as-is.
These need to be unquoted for the same reason that the left-hand side of a
let
binding needs to be unquoted - because these are pulled into scope as variables.This simplifies the evaluation we can eliminate recursive dicts during the
Expression
toTerm
conversion by transformingrec { a = x; b = y; }
intolet a = x; b = y; in { inherit a b; }
(and describing that transformation serves well to document the semantics of recursive dicts).