I am looking for a possibility to store information in parallel for a function and change the information when a function is called.
It seems possible to solve this problem by using
DownValues of a function. Imagine I use
makeFileCache[stream_, cacheSize_] := fileCache[OpenRead[stream], cacheSize]; fileCache[stream_, cacheSize_]["Size"] := cacheSize; fileCache[stream_, cacheSize_][newCacheSize_]:= ???; f = makeFileCache[STREAM, 12]; (* use arbitrary STREAM here. *)
This way I could for example
in order to get the
DownValue of the cache size. But is there a possibility to set it directly when calling? I know it is possible to manipulate it directly, this is not what I ask for. I look for a possibility to replace the question marks and directly work on the function
f and change its underlying parameters.
As I didn't know what exactly to look for it might be possible (and probable) that this question is a duplicate. Hints are appreciated.