Dfn lexical closures versus tradfn debuggability when error guards must cross paradigm boundaries
0 reputation · 18 Nov 2021, 22:42 UTC
A new Dyalog APL codebase will mix direct functions (dfns) and traditional functions (tradfns).
The team must adopt a single error‑handling convention and retain the ability to suspend execution during development.
Dfns capture surrounding namespace state lexically at definition time, enabling closures and tail‑call optimization, but their :: error guards only trap errors inside nested dfns, not errors raised by called tradfns. Tradfns provide uniform :: guards that catch errors in both dfns and tradfns and support full line‑by‑line debugging, yet they lack lexical closures and tail‑call optimization. Additionally, dfns cannot be suspended mid‑execution, while tradfns allow full workspace inspection.
Therefore the design decision is whether to standardize on dfns or tradfns for new modules when a uniform error‑handling style and routine debugging suspension are required.
Should new modules default to dfns or tradfns when error handling must be uniform and debugging suspension is required? Is there a pattern to bridge dfn error‑guard asymmetry without wrapping each cross‑paradigm call? Does 18.2 dfn tracing sufficiently improve dfn debuggability for production workflows?