No, I don't think so. A typical API (Application Program Interface
From: (e-mail address removed) (Richard Tobin)
That's an ABI (Application Binary Interface), not a typical API.
I don't want to get into a big argument over what each of us
prefers to *call* something, that's a fruitless exercise. To my
mind, what you call an ABI is a special case of API. An API in the
generic sense is *documentation* as to how to call the system
utilities, together with "what's really happening under the hood".
Under the hood it's always binary. Whether it's expressed as
assembly language or C or Pascal is irrelevant.
My experience comes from the Macintosh, specifically System 6.0.3
where I interfaced in **binary** using Macintosh Allegro Common
Lisp 1.2.2, Pocket Forth, and Sesame C as an outer framework, but
all actual code I wrote involved hexadecimal opcodes for the OS or
toolbox traps and machine-level textual names like assembly
language for the individual registers (for OS traps that took
parameters and returned results in registers and in parameter
blocks linked from these registers) and pre-defined push/pop stack
callables ("functions" in Lisp, "words" in Forth, I forget what in
Sesame C).
The documentation for this API was in a multi-volume technical
document called "Inside Macintosh". It gave an "under the hood"
general explantion of how these traps worked, that you push
parameters on the stack (for toolbox traps. the high-level
routines) or allocated a block of memory of a particular size and
organzation to hold essentially a STRUCT of parameters and put a
pointer to that block in a register (for OS traps, the low-level
routines). For OS traps, you copy parameters into slots in that
parameter block and/or load other registers individually. Then you
execute the special opcode for that particular trap. Then you
unwind the stack or copy data out of the parameter block and/or
individual registers.
Then in the sections dealing with individual traps, it showed the
PASCAL code for calling the trap, and also cited the opcode in
hexadecimal. If you had MPW (Macintosh Programmer's Workshop)
installed on your Macintosh, which I didn't because it was too
expensive for my budget even when I had a paying job, it was all
pretty easy. Otherwise you had to make do, as I did, handcoding the
hexadecimal opcodes and hand-arranging the stack operations or
parameter-block building and destructuring. Note that Inside
Macintosh did **not** specify any C interface. If you had MPW you
needed to read your MPW documentation to see how to relate the
PASCAL documentation to what you really needed to code in C. If you
didn't have MPW, then you had to "roll your own", as I did.
So would you consider "Inside Macintosh", when used by somebody who
doesn't code in Pascal and doesn't have MPW available, to be an ABI
or API per your particular use of languaage?
MACL 1.2.2 had a rather nice set of functions and/or macros (long
time since I had a computer that could run MACL so don't expect to
remember such details) for building/destructuring the parameter
block and loading/fetching the individual registers. Pocket Forth
has a set of "words" that are almost as easy to use. Sesame C
didn't have anything nice at all. In Sesame C I would have to
manually embed the hexadecimal bytes for the traps in an assembly
language module that satisfied the C function-calling conventions,
and then link it as an assembly language module into the C program
build, and call it as a function from main() directly for test
purposes or indirectly in an application. About the only OS trap I
ever coded for Sesame C was allocating a block of memory, because
Sesame C didn't have malloc() so I had to write my own malloc()
from scratch using OS traps to get the memory and OS traps to
release it when I called my own free(). Unfortunately invoking a
separate OS trap for each malloc() call was horrendously slow, so
then I re-wrote it to allocate a huge block once then sub-divide it
to satisfy malloc() requests. By comparison, in MACL I implemented
high-level parameter-validating functions to interface to
manipulation of "resources", allowing me to examine and remove the
WDEF virus that had infected most of my diskettes, and to the
simple-harmonic-tone generator, allowing me to add "good" and
"wrong" sound effects to my flashcard-drill program, and allowing
me to play simple tunes from MACL using exactly the same syntax
that the HyperTalk "play" command used, and a few other kinds of
traps I forget now.
My Macintosh Plus died in mid-1999, so I haven't done any of this
for over ten years. MACL 1.2.2 doesn't run under System 7.5.5 on my
Macintosh Performa, and being unemployed this whole time I couldn't
afford to upgrade to MACL 1.3.2 which is said to work fine on this
system, so I couldn't continue my Inside Macintosh work using MACL.
Sesame C so totally sucks that I would rather avoid using it. No
malloc (except the crock I wrote myself), no STRUCTs at all, only
two data types 'int' and 'void*', no arrays at all (that's why I
needed malloc, to emulate arrays and STRUCTs), you get the
picture??? Talk about C being a high-level assembly langauge,
Sesame C isn't even that, it's a mid-level assembly language.
So that leaves Pocket Forth as the only programming system on my
Macintosh that is possibly worthwhile for coding toolbox/OS traps
and higher-level software based on them. Someday soon I may
implement a subset of Common Lisp, with no garbage reclamation, or
with a reference-count system, based in Pocket Forth, hopefully
portable to just about any Forth anywhere in the world, with a
per-OS-API low-level layer to provide a machine-independent
Forth-API, and everything above that layer exactly the same in all
Forths on all OSs, true portability.