Turnkey
A "turnkey"-application in FORTH is a standalone executable for an application implemented in FORTH. Such an executable does not necessarily need to contain a full powered interpreter/compiler for FORTH. There are various strategies to generate turnkeys - Reva uses precompiled and compressed memory images . Reva does not attempt to remove overhead in the binary - so make sure you've loaded only necessary things for production binaries.
In Reva it is extremely easy to create a "turnkey". Use the save word:
save myapplication (in Linux... in Windows you'll want to add '.exe')
A better way is:
" myapplication" makeexename (save)
The makeexename word takes a basename and returns the appropriate type of name for an executable program on that platform.
After executing save, Reva will quit and the file you specified will have been created. Executing that (new) program will bring up Reva with whatever words you defined before typing save.
Note well:
You will probably not want to generate a turnkey after you have been "messing around", and particularly not if you used the help word. The reason is that you will have a lot of things in the dictionary and code space which are not desired by you (well, unless they are desired!).Issues:
- If you used the word allocate at the interpreter level (e.g., not within a colon-definition, or within one that was called outside of one) the memory allocated will not be saved with the application. That is because allocate gets memory from the OS at runtime, and that memory is not necessarily in the application's memory space.
- Similarly, if you used one of open/r open/rw create to get a file handle, that handle will not be valid after you save because it is a transient resource.
- Likewise with sockets, or Windows handles
You can customize the behavior of a turnkey by assigning your own word to appstart, which is a deferred word.
Examples of how to make a turnkey are in 'examples/makeexe.f' and 'examples/special.f' and some others in the examples directory.