Inline function
An inline function is a function defined or designated for incorporation at its use site, either syntactically or through compiler substitution, rather than necessarily invoked through an ordinary call.
Modern C
inline is a C function specifier that permits a function definition to be suitable for direct integration into callers without changing its semantics.
- How it is used
- Uses inline functions to expose small operations for optimization and to replace function-like macros when argument types are known.
- How deep it goes
- Explains call-site optimization and header layout, while making actual inlining a compiler choice rather than a guarantee.
- Examples
- Contrasts squaring a counter through a macro and an inline function, then shows a header definition with a separate declaration.
- What you can do after
- Build it from scratch: define a typed inline helper in a header and arrange its instantiation in one translation unit.
Modern C, Third Edition
inline is a C function specifier that permits a definition to suggest inline substitution of a function's body at call sites without requiring the compiler to perform that substitution.
- How it is used
- Uses inline for small functions that may benefit from call-site optimization and for typed replacements for function-like macros.
- How deep it goes
- Explains definition visibility, call overhead, optimization opportunities, and a header-plus-one-translation-unit arrangement without promising substitution.
- Examples
- Contrasts squaring a side-effecting call by macro and inline function, then illustrates a header definition and its companion declaration.
- What you can do after
- Apply inline to suitable small functions while preserving typed calls, arranging visible definitions, and measuring any claimed performance gain.
Kotlin in Action, 2E
An inline function is a Kotlin function whose body can be substituted at its call sites by the compiler and which can declare reified type parameters.
- How it is used
- Enables efficient higher-order helpers and collection operations while permitting non-local returns from their lambdas.
- How deep it goes
- Explains call-site bytecode substitution, lambda restrictions, performance tradeoffs, and reified runtime type checks.
- Examples
- Uses a locking helper, collection filter/map operations, and filterIsInstance on a mixed String and Int list.
- What you can do after
- Apply it via Kotlin inline and reified declarations to design small lambda-taking helpers and runtime type checks.
Grokking Simplicity
A function defined at the place in a program where it is used rather than assigned to a separate name.
- How it is used
- Uses short anonymous callbacks directly with higher-order functions such as map and withLogging.
- How deep it goes
- Defines inline, anonymous, global, and local functions, then demonstrates callbacks and refactoring limits.
- Examples
- Uses customer emails, greetings, logging, and purchase filtering and mapping to demonstrate inline callbacks.
- What you can do after
- Apply inline functions as map callbacks and recognize when naming a function improves reuse and clarity.
Related concepts
- functionkind of · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- function-like macrocontrasts with · A function-like macro is a macro invoked with function-like syntax that accepts token input and expands or transforms it into generated source.
- header fileconfigures · A header file is a source file containing declarations, definitions, macros, or other interface information intended for inclusion in one or more source files during compilation.
- filteringincludes · Filtering is the operation of selecting or excluding items from data or a collection according to specified criteria.
- non-local returnuses · A non-local return is a control-flow transfer that exits an enclosing function or computation from within nested code.
- lambdauses · A lambda is a language construct that defines an unnamed function or callable, often as a value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



