Service Provider Interfaces =========================== Use cases: * Optional dependencies * Load-time multiple implementation * Something like symbol interposition (e.g. fakeroot) * Things that can be overridden in an arena / Runtime multiple implementation * Perhaps even for things like Java/C#-style interfaces? Syntax? * Fully hidden? I.e. "normal" function/method calls. * Fully hidden, but allow only calls "on" an arena-allocated object? * Special syntax? spi(arena_obj).do_stuff(x, y, z) do_stuff(spi(arena_obj), x, y, z) * Or declare only certain methods as SPI methods? func overridable arena Thing.work() func overridable do_stuff(arena) - Problem: Sometimes an API can ONLY be overridden as a whole! (for example: resource aquisition + release) - Better use "libraryspec" for these kinds of things? And then allow an implementation to be selected for the arena (but how to handle recursive invocations?) - Or something like interfaces? With some kind of default impl? Problems: * Performance of calls to exported functions, if they can be overridden. * Possible bypassing of access checks if the functions used by the access check can be overridden by other code (i.e. untrusted code). - UNLESS the code loses ALL privileges. Alternative solutions: * Optional dependendencies: YES. These would require a boolean check (similar to option types), and would require some special syntax to indicate that a function requires it. - E.g.: depends "PKGNAME" - Maybe also: depends "PKGNAME" >= "1.0"? - And have \depends with "upto"? - What should the syntax for checking be? Perhaps module_available(arena, "PKGNAME") ? * Load-time multiple implementation: YES. Can be controlled with symlinks on Linux and some loader configuration file for system-independent configuration.