It’s been some time since I delivered an update on OspreyForth, so here it is.
OspreyForth is chugging along. Initially I planned to use pForth as the interpreter, but I’ve changed to GForth. My choice for pForth was for two reasons. First, it is public domain, which seemed like a good choice. Secondly, GForth’s manual continually makes claims of incompleteness and has consistently noted over the course of years that the foreign function interface (the ability to interface to C libraries) is incomplete. pForth’s is very complete and seems very easy to use.
Unfortunately, I ran into a problem translating pForth strings to C strings. Specifically, the first character of C string would drop off when translating from a Forth String to a C string and then back again. This is obviously problematic. The problem is compounded by the fact that when interfacing with the Objective-C libraries one is required to use the NSString object for everything string-related. The only way for Forth to create an NSString is to pass a C string. This clearly represents a problem when the first character is consistently being lopped off in the process.
Because of this, and because I was working on OspreyForth for a game project at the time, I decided to move to GForth. It’s more popular anyway and presumably more consistently worked on. I hope so, anyway. The problem with the GForth interface as I’ve discovered is that it doesn’t have a callback mechanism. This means I can call and manipulate Objective-C objects, but I cannot create one since that would require the Objective-C runtime to call the GForth runtime for information. This is fine for the time being, however, because I only currently intend to manipulate objects. I would like to make them, but that can be handled at a later date.
OspreyForth is now a GForth library rather than a self-contained system as I’ve imagined it in the past. I have succeeded in instantiating an NSString object and I appear to be able to manipulate it. This is critical for reasons mentioned above. I need to attempt to instantiate and manipulate other objects as well to be sure the system is usable. After this, I will work on accessing as much of the Objective-C runtime as possible. When everything seems to work properly, I will upload to SourceForge under an amenable license and continue working from that repository rather than my computer at home. When I’m satisfied with its usefulness I will begin work to use it in a production sense at work and home for various projects.
So far so good!