The only thing I think we miss for this is ways to associate (and query)
arbitrary metadata to an attrset key, including one that is not
associated with a value. With this I think everything proposed can be
done with__functor
-based magic.
Actually thinking about it again (and having seen shlevy’s nixcon talk
for metadata):
We don’t actually need a syntax for defining or reading metadata, we can
just standardize on metadata.[attrname].[metadataname]
However, the feature we do need is late-binding of variables. In an
extensible attrset I want { a = 1; b = a; }
to not be resolved
immediately. So this would need late-bound variables. For instance, the
above attrset could be expanded to { a = {...}: 1; b = {a, ...}: a; }
.
All of this could be made manually, but nix-provided tooling would be
really helpful. However, I do think a late { a = 1; b = a; }
(or
whatever other name) would be a really important first step, because no
one wants to write one function per attribute. Then special syntax for
setting the metadata.
I guess my idea is this one: If we can make smaller primitives, then
they can be used in more places than we would even expect.
(oh, also I’d love metadata for function arguments, but this one is not
going to be solved by adding metadata.[attrname].[metadataname]
…
unless we turn all functions into attrsets with __functor
… food for
thought)