Can't store a function in Memory

  • When I try to store a function in Memory (no matter how deeply nested), I get an error:

    >[0] = function(){}
    Error: Failed to execute 'postMessage' on 'WorkerGlobalScope': An object could not be cloned.
        at Error (native)
        at DedicatedWorkerGlobalScope.self.onmessage (blob:https%3A//

    Is this intentional?

  • Memory is stored as JSON between turns. JSON doesn't support storing javascript functions, it only supports storing objects, array, number, string and nulls.

  • You may be able to do:[0] = function(){}.toSource()

    Curious though, why do you want to do that? It takes more space and doesn't really convey any real info.