You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import future
typeFunc0*[R] = () -> R
# This definition fails too# Func0*[R] = proc(): R# This definition leads to errorprocmemoize*[T](f: Func0[T]): Func0[T] =# And this is not# proc memoize*[T](f: () -> T): () -> T =## Create function's value cache (not thread safe yet)var hasValue =falsevar value: T
result=proc(): T =ifnot hasValue:
hasValue =true
value =f()
return value
whenisMainModule:
var x =0let f = () => (
inc x;
x
)
let fm = f.memoize
echof()
echofm()
echof()
echofm()
fails to compile:
/home/vega/work/nim/nimfp/src/fp/nimcache/nimfp_functions.c: In function ‘HEX3Aanonymous_101125’:
/home/vega/work/nim/nimfp/src/fp/nimcache/nimfp_functions.c:341:37: error: called object is not a function or function pointer
(*HEX3Aenvp_101135).value101124 = (*HEX3Aenvp_101135).f101120();
^
/home/vega/work/nim/nimfp/src/fp/nimcache/nimfp_functions.c: In function ‘functionsInit000’:
/home/vega/work/nim/nimfp/src/fp/nimcache/nimfp_functions.c:478:9: error: called object ‘fm_101142’ is not a function or function pointer
LOC4 = fm_101142();
^
/home/vega/work/nim/nimfp/src/fp/nimcache/nimfp_functions.c:237:13: note: declared here
Func0101113 fm_101142;
^
/home/vega/work/nim/nimfp/src/fp/nimcache/nimfp_functions.c:490:9: error: called object ‘fm_101142’ is not a function or function pointer
LOC8 = fm_101142();
^
/home/vega/work/nim/nimfp/src/fp/nimcache/nimfp_functions.c:237:13: note: declared here
Func0101113 fm_101142;
^
The text was updated successfully, but these errors were encountered:
This code:
fails to compile:
The text was updated successfully, but these errors were encountered: