Making an .exe that executes source file inside itself.

JN 666total at wp.pl
Thu Apr 26 10:06:57 UTC 2018


On Wednesday, 25 April 2018 at 19:19:58 UTC, BoQsc wrote:
> So there has been idea I've got for around few months now: 
> making a software which executable would contain a source file.
> A software that anyone could modify by opening an executable 
> and quickly change a few lines of it, rerun an executable, see 
> the changes.
>
> Could this be easily possible with D language, considering that 
> sources files can be ran without long slow compilation process?

If it makes sense for your project, you could embed a scripting 
language with LuaD or PyD and rerun the script whenever it 
changes.

Alternatively, I don't know about specifics how to implement it 
in D, but the key phrase you are looking for is "code hotswap" or 
"hot loading". It's being popularized right now in gamedev 
circles, to avoid slow complications of the code. The way to do 
it is push code into DLLs, then reload the DLL if the change is 
detected. Of course it's not that simple, because there are some 
tricky parts around DLL boundaries and you have to reload the 
entire state, but it is possible. In such case, rather than 
recompile the entire code, you can just recompile a small subset 
of functionality to a DLL.


More information about the Digitalmars-d-learn mailing list