This is a naive question, but in the tutorials I have seen so far is not spelled clearly.
If I build a interpreter on top a high-level language (not C, C++, etc) and this have a garbage collector... is necessary to also make one for the interpreter itself?
And if the answers is yes... it must be the same kind of the host? (ie: If the host is mark-sweep, the interpreter too?), or is possible to leverage the host and let it manage all of this?
The selection of host make a difference? I plan to use F#/.NET, but is the same for Java and others?
Best How To :
The memory management of the interpreted language can piggy-back on the memory management of the host, but if you are implementing a non-toy interpreter, you may need to use weak pointers for the administrative references from the host to values of the interpreted world that should be garbage-collected if there are no references to them left in the interpreted world.
If you are implementing a toy interpreter, no one may even notice if you use strong pointers for administrative references from the host world to the interpreted world. In this case, I would recommend you don't bother: weak pointers, as a feature, are available in all sufficiently advanced memory-managed languages, but the details differ and their use is always tricky. Bruno Haible's survey provides a picture of all the varieties. In his survey, this use of weak pointers falls under “Global garbage collection: Allow garbage collection to work across process boundaries, or across a Lisp - C/C++/Java foreign interface boundary”, except that the foreign interface boundary is between the host language and the interpreted language.