Hey I'm looking for a solution to some problems that i have using Julia as a general purpose language. Given that there are no access modifiers i cannot restrict people calling functions i don't want them to call. Use case is a game (yeah that's somewhat new territory) that has its codebase (provided by me) but allows scripting the environment (within some borders also outlined by me). Examples would be spawning some plants/animals etc. manipulating what happens on clicking and so on. All stuff that changes your experience in the game.
But i clearly don't want people do be able to accidentally harm their computers by downloading/removing/creating anything in their file system. The other obvious reason is that i don't want people to be able to open a file stream download a virus and execute it (what theoretically would be possible). This is no problem in a singleplayer game but imagine it being multiplayer. This case could also be handled by just not sharing stuff or having no multiplayer but i think you get my problem. The next problem that also results from the very same game idea was the following: Mind you've got some automation tool that does anything on its own (like protecting you like a shield) now say this shield does something scheduled as well. Since this is all coded by the player there are no real hooks in his code. So what can i do to preserve the current state of the execution of this script in case he leaves the game or pauses it. (Means i need something to make the current execution state persistent aswell as being able to stop it at any given point and of course resume it later) This problem leads to something similar to an interpreter or even debugger (or even more abstract a VM, but i think that'd be overkill) but for the current existing ones they clearly don't focus on persistence and the ability to yield after like 10 execution steps. A perfect solution to this problem would be some sort of scheduler for the interpreter/debugger that can save the state of it's scheduled program. But sadly something like that doesn't exist (at least i didn't find it). So are there any tips/workarounds to come nearer to my dream of game? Partial solutions/solutions/ideas etc even for "only" one of the problems are highly appreciated. Of course i know these problems are very special but I'm sure that having more people reading it might result in some very nice ideas.
