Extending Bif-C

I have to warn you here, this is getting close to the edge of the world. You could fall off, so keep a safety net handy. Metaphorically speaking.

Moe specifically, what I'm explaining here will change. I put it together in a rush for the class I was taking at Polytec Hyogo, and I didn't stop to do it right.

What will change, though, is how to link the new definitions in. When I get that working, I'll try to remember to come fix this.

The files bif_ex.c and bif_ex.h show how to chain in new definitions, and how to write "low level" definitions in C.

Examine the source in general to understand the difference between a "low level" definition and a "high level" definition. One looks like a parameter-less function, and the other is a list of pointers to symbol table headers. (In fig-FORTH, these pointers point within the symbol table entries, and I could have done that, but I didn't want to push the C syntax too far.)

You have to explicitly push parameters. Look at the LIT word for clues how to do that in high-level. That is, you can often use LIT to do the job for constants.

After you add new definitions to bif_ex.c make sure the headers (and, for low-level, the functions) are declared in bif_ex.h.

Make sure that LASTinIOEX is defined as the last definition in bif_ex.c.

Look at the definition of definition_header_s in bifu_i.h for descriptions of the header fields.

Look at the headers in bif_ex.c to see how the definitions are linked into the allocation list, last to first, and how they are linked into their vocabulary. Without these links you wont be able to find them at run-time.

The definitions OPEN_LEDS through READ_LCD are specific to the embedded environment I was working on at Polytec Hyogo and won't be of use without the hardware or the drivers, other than as examples. Running them will only produce error messages from the C run time, so they aren't particularly dangerous to have compiled in. But I'll try to come up with some better examples, later.

That's about all I have time for now.