📝Symmetric vs asymmetric multiple dispatch

§ Multiple dispatch is symmetric if all function arguments play equal role in determining the implementation used.

CLOS (Common Lisp: Multiple Dispatch) is asymmetric because first argument takes precedence.

Asymmetric multiple dispatch has a deterministic resolution—if there are multiple matching implementations, it will always peek one. (Symmetric one can lead to ambiguous resolution.) However, the priority rules are somewhat arbitrary and that may lead developers to change the code to satisfy the priority rules (e.g., changing parameters order).

Backlinks

Want to receive my 🖋 posts as I publish them?