1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-25 19:51:00 +01:00
Nix, the purely functional package manager
Find a file
Eelco Dolstra c3a79daaf3 * Short-circuiting of function call evaluation.
With maximal laziness, you would expect that a function like this

    fib = n:
      if n == 0 then 0 else
      if n == 1 then 1 else
      builtins.add (fib (builtins.sub n 1)) (fib (builtins.sub n 2));

  can be evaluated efficiently, because maximal laziness should
  implictly memoize the recursive calls to "fib".  However, non-strictness
  interferes with this: the argument "n" is generally not in a form
  that allows the memoization to work (e.g., it will be something like
  (20 - 1 - 2 - 2) rather than 15).  By the time that "n" is
  evaluated (in "if n == 0 ..."), we're already deep in the evaluation
  of the call.

  (Strictness solves this:

      builtins.add (strict fib (builtins.sub n 1)) (strict fib (builtins.sub n 2));

  but that's not a very nice approach.)

  With short-circuiting, the evaluator will check after evaluating a
  term, whether that term is the argument of a function call that
  we're currently evaluating.  If so, it will check to see if the same
  call but with the evaluated argument is in the normal form cache.

  For instance, after evaluating (20 - 1 - 2 - 2) to 15, if we see
  that "fib (20 - 1 - 2 - 2)" is currently being evaluated, we check
  to see if "fib 15" is in the normal form cache.  If so, we unwind
  the stack (by throwing an exception) up to the evalExpr call
  responsible for "fib (20 - 1 - 2 - 2)", which can then immediately
  return the normal form for "fib 15".  And indeed this makes "fib"
  run in O(n) time.

  The overhead for checking the active function calls (which isn't
  very smart yet) seems to be modest, about 2% for "nix-env -qa
  --drv-path --out-path" on Nixpkgs.
2007-10-12 17:53:47 +00:00
blacklisting * This is a better location to keep the blacklist, since it can evolve 2005-03-24 14:07:02 +00:00
corepkgs * nix-env: allow ~/.nix-defexpr to be a directory. If it is, then the 2007-09-17 16:08:24 +00:00
doc * Manpage for nix-copy-closure. 2007-09-19 14:01:41 +00:00
externals * Use the new patched version of the aterm library. 2007-08-07 23:40:39 +00:00
make * `dependencyClosure' now allows a search path, e.g., 2005-08-14 14:00:39 +00:00
misc * Finally, a real "let" syntax: `let x = ...; ... z = ...; in ...'. 2006-10-02 15:52:44 +00:00
scripts * New command `nix-store --optimise' to reduce Nix store disk space 2007-10-09 22:14:27 +00:00
src * Short-circuiting of function call evaluation. 2007-10-12 17:53:47 +00:00
tests * Test the impureEnvVars feature. 2007-09-11 13:32:04 +00:00
aterm-gc.supp * New suppressions. 2006-03-01 15:40:01 +00:00
AUTHORS * Put something in here. 2004-11-07 20:30:02 +00:00
bootstrap.sh * Build dynamic libraries. 2005-07-22 14:52:45 +00:00
ChangeLog * Autoconf / Automake configuration and building. 2003-04-04 16:14:56 +00:00
configure.ac * Give unpacked channels more sensible names than 0, 1, ... They now 2007-05-01 23:16:38 +00:00
COPYING * Change this to LGPL to keep the government happy. 2006-04-25 16:41:06 +00:00
INSTALL * Autoconf / Automake configuration and building. 2003-04-04 16:14:56 +00:00
Makefile.am * nix-pull: using nix-prefetch-url (so that we get caching for free), 2007-08-09 23:52:53 +00:00
nix.conf.example * Kill a build if it has gone for more than a certain number of 2006-12-08 15:44:00 +00:00
nix.spec.in * Fix URL/description. 2007-03-21 12:39:55 +00:00
README * Add SHA-256. 2005-01-14 12:03:04 +00:00
substitute.mk * Give unpacked channels more sensible names than 0, 1, ... They now 2007-05-01 23:16:38 +00:00

For installation and usage instructions, please read the manual, which
can be found in `docs/manual/manual.html', and additionally at the Nix
website at <http://www.cs.uu.nl/groups/ST/Trace/Nix>.


Acknowledgments

This product includes software developed by the OpenSSL Project for
use in the OpenSSL Toolkit (http://www.OpenSSL.org/)