Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Proxy and Lykn’s Surface Language

Surface Lykn’s functional patterns cover many use cases where other languages reach for metaprogramming:

NeedProxy ApproachLykn Surface Approach
Validationset trap:pre contracts (Ch 8)
Immutabilityset/delete trapsbind + cell (default)
Default valuesget trapDestructuring defaults (Ch 15)
Loggingget/set trapsswap! callback (Ch 13)
Reactive stateset trap + notifycell + observer pattern

Proxy is the escape hatch for cases where surface patterns aren’t enough — typically when you need to intercept operations on an object you don’t control: a library’s return value, a DOM element, a third-party API response.

If you’re intercepting your own objects, contracts and cells are simpler. If you’re intercepting someone else’s, Proxy is the tool.