18/09/15 17:38, David Matthews wrote:
On 18/09/2015 13:50, Phil Clayton wrote:
The only other changes I'm thinking about are:
- Introducing a "touch" primitive for long-term security in case a
future update to the optimiser means that the current "touch" becomes a no-op.
I think that would be a very good idea.
I've done that now. It's a new run-time system call which just returns 0. RTS calls are used for all built-in functions and it's possible for the code-generator to process simple ones directly inline. I haven't done that at the moment so it goes as far as a piece of assembly code.
Much appreciated. For now I'd like to get a version working on top of 5.5.2, and I assume assignment will suffice there. Is there a way to create a non-overwritable ref in a normal session? I don't seem to be able to access LibrarySupport.noOverwriteRef (and these seem to be needed for cleanAtExit to work).
Also, is there any point in Weak.weak taking an optional value? (Would anyone ever call it with NONE?) Presumably weak could add the required SOME to give val weak : 'a ref -> 'a ref option ref
My thinking was that you might have a finite set of resources, such as file descriptors, and a list of weak references or a weak array with an entry for each resource. When a resource was allocated a SOME entry would be made in the weak ref/array. If the resource was no longer reachable the corresponding entry would be set to NONE and the resource could be reclaimed and later reallocated.
I see now. I had overlooked the possibility of reusing one of these weak refs after it is NONE.
Phil