The Debug Adapter Protocol is a REPL protocol in disguise

https://news.ycombinator.com/rss Hits: 2
Summary

The Debug Adapter Protocol is a REPL protocol in disguise Table of content A couple months back I created nluarepl. It鈥檚 a REPL for the Neovim Lua interpreter with a little twist: It鈥檚 using the Debug Adapter Protocol. And before that, I worked on hprofdap. Also a kind of a REPL using DAP that lets you inspect Java heap dumps (.hprof files) using OQL. As the name might imply, a REPL isn鈥檛 the main use case for the Debug Adapter Protocol (DAP). From the DAP page: The idea behind the Debug Adapter Protocol (DAP) is to abstract the way how the debugging support of development tools communicates with debuggers or runtimes into a protocol. But it works surprisingly well for a REPL interface to a language interpreter too. Essentials 露 The typical REPL shows you a prompt after which you can enter an expression. You then hit Enter to submit the expression, it gets evaluated and you鈥檙e presented with the result or an error. The Debug Adapter protocol defines a evaluate command which - as the name implies - evaluates expressions. The definition for the payload the client needs to send looks like this: interface EvaluateArguments { /** * The expression to evaluate. */ expression: string; // [...] } With a few more optional properties. The (important bit) of the response format definition looks like this: interface EvaluateResponse extends Response { body: { /** * The result of the evaluate request. */ result: string; /** * The type of the evaluate result. * This attribute should only be returned by a debug adapter if the * corresponding capability `supportsVariableType` is true. */ type?: string; /** * If `variablesReference` is > 0, the evaluate result is structured and its * children can be retrieved by passing `variablesReference` to the * `variables` request as long as execution remains suspended. See 'Lifetime * of Object References' in the Overview section for details. */ variablesReference: number; // [...] } result is a string and there is optionally a type. The neat b...

First seen: 2025-12-05 23:17

Last seen: 2025-12-06 00:18