I just stumbled upon this suggestion that gives us namespace-like capabilites when working in C. This leverages function pointers in a way I never considered.
Looks good, I like this idea and it is a very good strategy for device driver models where the framework is agnostic and all devices implement some "interface".The Linux kernel uses similar 'namespace' functionality in most device driver interfaces.
https://www.kernel.org/doc/html/v4.10/driver-api/infrastructure.html
Simple example: https://raw.githubusercontent.com/torvalds/linux/master/drivers/staging/comedi/drivers/ni_daq_700.c
This is the most common way in which you use function-pointers to abstract access to things like devices through a single structure called a parameter block. This is used heavily in O/S queuing, window and control managers, and more.I just stumbled upon this suggestion that gives us namespace-like capabilites when working in C. This leverages function pointers in a way I never considered.