Dynamic dispatch
- Intent
- dispatch the control based on the environment, but delay enumerating the cases
- Motivation
- we don't know at the time of writing the code what are the different cases to dispatch on
- Implementation
- (nearly) invisible in php
- Examples
$case($arg);
$object->$method($arg);
call_user_func($calleable, $arg1, $arg2);
- Note
- A more elaborate form of dynamic dispatch is Method Chaining