Presented at Core C 2023 conference.
Classically, functions and methods use arguments in order to produce a variety of results. But at times, this means passing “configuration” arguments to many APIs, which may hit hard maintainability and readability. Alternately, classes introduce configuration APIs in order to affect their general behavior. But these require special care when shared objects are invoked from multiple threads.
In this talk a novel but simple approach is presented, which affects the behavior of code, depending on the calling context. It eliminates the need to refactor big APIs with configuration arguments, and it is completely thread safe. Most of all, it lends itself to a flow-centric approach, where desired behaviors map naturally to code scopes.
A few use cases will be presented, such as logging, decorators, event counting, dependency injection, and caching.
-----
Eran Talmor
In the past 20 years, I have been building formal-methods based CAD-tools for microprocessor and SOC design and verification. Currently I lead an R&D team in Cadence Design Systems, and previously I have worked for Intel in their CAD development group. I code C regularly, but also had non negligible experience with functional languages such as OCaml.