I always thought Amiga's "tag list" concept was really nice. You easily could extend the API w/o breaking the ABI, which was essential for its shared library concept. And it essentially gave you named arguments too.
Yes indeed. I've often wondered where it came from - did they invent it, or was it inspired by something on another platform?
(For the uninitiated, taglists are freeform lists of TAG / value pairs, which you would typically supply through varargs functions - something like OpenScreenTags(&newscreenstruct,SA_WIDTH,320,SA_HEIGHT,256,SA_DISPLAYID,myscreenmode,TAG_DONE); )
IMHO the main problems with this idea is that it isn't type-safe and it's wasting a lot of stack space for the tags.
> I've often wondered where it came from
Don't know but the other place where I've seen this idea is when initializing OpenGL contexts on some platforms. This involves defining attribute key/value pairs like this:
Yes, that was neat at the time: an array of key/value structs for extensibility. The "keys" were a #define somewhere in the header files. The original Amiga APIs (before OS 2.0) did not have tag lists and it was painful to work with.
I started learning C on an Amiga with OS 1.3, then moved to a 2.0 machine. Fun times.
A somewhat similar extension concept (in the sense of: allow to extend the API without breaking ABI) still exists in some C APIs, for instance in Vulkan each struct starts with an `sType` tag and a `pNext` pointer, this allows to build 'extension struct chains':
(For the uninitiated, taglists are freeform lists of TAG / value pairs, which you would typically supply through varargs functions - something like OpenScreenTags(&newscreenstruct,SA_WIDTH,320,SA_HEIGHT,256,SA_DISPLAYID,myscreenmode,TAG_DONE); )