Protocol
A protocol is a language construct that declares operations or requirements implementable by types, often enabling polymorphic dispatch.
Classic Computer Science Problems in Swift: Essential techniques for practicing programmers
A Swift language construct that specifies requirements for types to adopt without defining a class hierarchy.
- How it is used
- Uses protocols to design a flexible, protocol-first graph framework.
- How deep it goes
- Defines requirements, associated types, extensions, and adoption in a graph framework without developing broader protocol theory.
- Examples
- Demonstrates Edge, Graph, UnweightedEdge, UnweightedGraph, and a city adjacency-list graph.
- What you can do after
- Build flexible Swift graph types by defining protocol requirements and supplying concrete adopting types.
Clojure: The Essential Reference
A Clojure protocol is a named set of method signatures that types can implement and that is represented by a corresponding Java interface.
- How it is used
- Frames protocols as an efficient alternative to cascading instance? checks and a type-oriented choice alongside multimethods.
- How deep it goes
- Explains generated interfaces, dispatch lookup, implementation strategies, extension timing, metadata, and basic performance differences.
- Examples
- Demonstrates protocol inspection, String extension, direct and later implementations, numeric formatting, and polymorphic tree traversal.
- What you can do after
- Build it from scratch with defprotocol, implement methods directly, extend existing types, and inspect supported extensions.
Read how Clojure: The Essential Reference explains protocol →
Related concepts
- protocol-oriented programmingused by · A programming style that emphasizes protocols and composition over class inheritance.
- modulekind of · A module is a distinct, bounded software unit that groups related code or functionality and provides an organizational or interaction boundary within a larger system.
- CollFold protocolincludes · CollFold is a Clojure protocol that allows a collection to provide its own partitioned folding implementation.
- multimethodalternative to · A multimethod is a dispatch mechanism that selects an implementation by applying a dispatch function to multiple arguments, often using their runtime types or values.
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.

