The Decorator pattern allows behaviour to be dynamically added to an existing object, effectively "decorating" it with new behaviour. While the pattern as formalised and named seems to have been popularised by the "Design Patterns" book in 1994 by the Gang of Four, I'm curious about its origins.
In functional programming, higher-order functions can wrap other functions to add behaviour without changing their signature. In modern programming, this is frequently referred to as "decorating" - particularly in e.g. Python, Go, but also generally pretty much anywhere higher-order functions are available. This was presumably a "pattern" in ML, in Lisp, or even potentially in λ-calculus almost 60 years prior to the publication of the GoF book. In particular, I've seen examples of memoization in functional programming (replication of which is frequently a textbook use-case for the decorator pattern in OOP) going back to at least the late 60s.
- Was this specific case (more general than memoization, but more specific than function composition in general) a formal concept in functional programming literature?
- Was it called "decorating", and the GoF named the pattern after it, or is it now called "decorating" after the GoF pattern?