liveBook · Manning

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.

How 4 Manning books explain it

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.

Read how Modern C explains inline function →

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.

Read how Modern C, Third Edition explains inline function →

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.

Read how Kotlin in Action, 2E explains inline function →

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.

Read how Grokking Simplicity explains inline function →

Related concepts

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.