# -*- nim -*- # # About SKI combinator calculus: # # //en.wikipedia.org/wiki/SKI_combinator_calculus#Informal_description # # About the NIM language: # # //nim-lang.org # # compile with: # # nim c --skipParentCfg -d:release skk.nim # # and use: # # gcc -E -I`nim dump 2>&1 >/dev/null|sed '$!d'` nimcache/skk.c | # indent | # grep -v -e '^#' -e '^$' | # less # # for inspecting the generated C code at # # ./nimcache/skk.c # # Search for functions starting with "skk_" and "i_" and verify that both # functions are the identity function. # # Note that: # a b is short for a(b) # a b, c, d is short for a(b, c, d) # a b c is not understood by NIM import os template S(x, y, z: untyped): untyped = x(z, y z) # macro template K(x, y: untyped): untyped = x # macro proc skk[T](x: T): T = S K, K, x # generic function for type T proc i[T](x: T): T = x # generic function for type T let exeName = paramStr(0).cstring # cstring => avoid string copy doAssert skk(exeName) == i(exeName) # End