summary refs log tree commit diff stats
path: root/lib/core
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2019-04-11 22:09:11 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-04-11 23:09:11 +0200
commit041d15392aaf732665abab290f0cf5993d909efc (patch)
tree4a4aff6b33707850f7e38e680652bf00e6c5c0df /lib/core
parentde02fd0b898e41fa91087300d82573d83e357b34 (diff)
downloadNim-041d15392aaf732665abab290f0cf5993d909efc.tar.gz
Compiler plugin for implementing incremental computation in user space (#10819)
This plugin provides essential building block for implementing incremental computations in your programs. The idea behind incremental computations is that if you do the same calculation multiple times but with slightly different inputs you don't have to recompute everything from scratch. Also you don't want to adopt special algorithms either, you would like to write your code in standard from scratch manner and get incrementality for free when it is possible.

The plugin computes the digest of the proc bodies, recursively hashing all called procs as well . Such digest with the digest of the argument values gives a good "name" for the result. Terminology loosely follows paper "Incremental Computation with Names" link below. It works well if you have no side effects in your computations. If you have global state in your computations then you will need problem specific workarounds to represent global state in set of "names" . SideEffect tracking in Nim also useful in this topic.

Classical examples:

Dashboard with ticking data. New data arrives non stop and you would like to update the dashboard recomputing only changed outputs.
Excel spreadsheet where user changes one cell and you would like to recompute all cells that are affected by the change, but do not want to recompute every cell in the spreadsheet.
Diffstat (limited to 'lib/core')
-rw-r--r--lib/core/macros.nim7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 6525770eb..d27d97f2f 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -360,6 +360,13 @@ when defined(nimHasSignatureHashInMacro):
     ## the owning module of the symbol and others. The same identifier is
     ## used in the back-end to produce the mangled symbol name.
 
+proc symBodyHash*(s: NimNode): string {.noSideEffect.} =
+  ## Returns a stable digest for symbols derived not only from type signature
+  ## and owning module, but also implementation body. All procs/varibles used in
+  ## the implementation of this symbol are hashed recursively as well, including
+  ## magics from system module.
+  discard
+
 proc getTypeImpl*(n: typedesc): NimNode {.magic: "NGetType", noSideEffect.}
   ## Version of ``getTypeImpl`` which takes a ``typedesc``.