From 36252cb88299178a7925d59d1b2a991c0cc02ce8 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 28 Oct 2021 22:29:52 +0100 Subject: [PATCH] Clarify how lazy evaluation helps to escape infinite co-recursion. In pill 13 `callPackage` and `pkgs` are defined co-recursively. The author notes thas this is possible due to lazy evaluation, but for some readers this may be confusing (as if lazy evaluation was some kind of magic that makes infinite recursion not a problem). --- pills/13-callpackage-design-pattern.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pills/13-callpackage-design-pattern.xml b/pills/13-callpackage-design-pattern.xml index 1a040ff..a8ab5b2 100644 --- a/pills/13-callpackage-design-pattern.xml +++ b/pills/13-callpackage-design-pattern.xml @@ -115,7 +115,7 @@ Note how easy is to override arguments in the case of graphviz without gd. But most importantly, how easy it was to merge two repositories: nixpkgs and our pkgs! - The reader should notice a magic thing happening. We're defining pkgs in terms of callPackage, and callPackage in terms of pkgs. That magic is possible thanks to lazy evaluation. + The reader should notice a magic thing happening. We're defining pkgs in terms of callPackage, and callPackage in terms of pkgs. That magic is possible thanks to lazy evaluation: builtins.intersectAttrs doesn't need to know the values in allPkgs in order to perform intersection, only the keys that do not require callPackage evaluation.