Scenario: a course running inside a byte code virtual machine like Java or Python, really wants to evaluate (by producing quickly to byte code after which running) a function whose code was instantly produced or provided from outdoors.
The tricky bit would be that the function's code isn't reliable -- it might have been produced with a stochastic method like genetic programming, as well as provided by an foe. It is therefore preferred to enforce it reacts like a pure function -- it may return something, but it might not have unwanted effects, i.e. it might not alter the program's existing data by any means.
Another tricky bit would be that the function could have a legitimate have to call a few of the program's existing functions a few of these functions might have unwanted effects, however these ought to be avoided from really getting any lasting effect as lengthy because they are being known as through the suspect function.
Also, it's more suitable that no constraint go around the coding type of the suspect function, e.g. it's liberated to perform destructive updates on data structures it produces itself, only its overall effect is needed to become purely functional.
In addition, it's more suitable the solution have reasonably low overhead, as this might need to be achieved vast amounts of occasions it might be better, for instance, to prevent needing to fork another virtual machine for every such function.
This does not always need to be possible within an existing virtual machine like Java or Python if it's essential to design an online machine for this use situation, then so whether it is.
What are the already known solutions (or non-solutions, i.e. stuff that are known to not work) with this problem?
I'd imagine sandboxing is the only option. Attempting to evaluate this program and see if it's safe is really a halting problem equivalent. The CLR has security built-in that permit limitations such as this, I imagine Java has similar ones. I do not think Python does.
Well, the overall problem appears to become unsolveable: there is not a terminating technique for sorting naturally stateful computations in the possibly condition-free. Unless of course the byte code is particularly built to supply the type strong type constraints needed to beat this, then you will be lost. Curien has written much by what type of things can and should not be deduced from black box findings.
But when you are prepared to require more out of your function provider, now you ask , pleading for proof-transporting code (PCC) being an answer. I am speculating you understand the work of Necula, who had been particularly worried about making certain that set up code respected constraints on memory usage, for example not tampering without having-of-scope condition you will possibly not be familiar with the job done on automatic inference of proofs in not unheard of cases: it might be that PCC is definitely an simpler option than you believe.
I, and many more have formerly built languages for genetic programming reasons. If creating a brand new language is definitely an option, then such solutions already is available. Since you will find approaches for automatic function generation, it ought to be trivial to supply function libraries. This technique will, essentially constitute a sand-boxed atmosphere. Any unwanted effects of those functions is going to be restricted to this program accessible space.