The Debug Adapter Protocol is a REPL protocol in disguise
Table of content
A couple months back I created nluarepl. It’s a REPL for the Neovim Lua interpreter with a little twist: It’s 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’t 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.
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’re 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 { EvaluateArguments { /** * The expression to evaluate. */ : string ; expression // [...] }
... continue reading