Re:C's designated initializers give us named arguments
by binaryturtle on Thursday November 19, 2026 @08:16AM
(#50559702)
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.
[ Parent
| on HN ]
Re:C's designated initializers give us named arguments
by flohofwoe on Thursday November 19, 2026 @09:53AM
(#50560911)
This extension concept 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':
https://docs.vulkan.org/refpages/latest/refpages/source/VkDe...
Re:C's designated initializers give us named arguments
by robinsonb5 on Thursday November 19, 2026 @09:53AM
(#50560919)
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); )
Re:C's designated initializers give us named arguments
by flohofwoe on Thursday November 19, 2026 @10:04AM
(#50561055)
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:
int attributes[] =
{
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_STENCIL_SIZE, 8,
GLX_DOUBLEBUFFER, True,
None
};
Of course OpenGL is a bit later than AmigaOS, but not by much :)
Re:C's designated initializers give us named arguments
by kevin_thibedeau on Thursday November 19, 2026 @11:32AM
(#50562283)
XView worked similarly. It had a small handful of variadic functions for its API that you passed lists of arguments into.
Re:C's designated initializers give us named arguments
by icedchai on Thursday November 19, 2026 @09:56AM
(#50560944)
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.