Hacker News new | ask | show | jobs
by dogprez 870 days ago
> [Fennel] also lacks Common Lisp's debuggability, given that it sits entirely within Lua's runtime.

I'm not sure exactly what feature the OP was referring to. It sounds like they don't think you can get a REPL for an executing Fennel process? You can. If you are only using it for AOT Fennel->Lua you can't, you have to include its runtime.

1 comments

Last I checked, Lua was “bring your own debugger”. Assuming that hasn’t changed, a REPL is nice, but you can’t pause and inspect anything by default.
To be the most fair, Fennel 1.4 recently released with an `assert-repl` form that opens a repl when some assertion fails, in which you can inspect local variables, etc. That's getting closer to CL.

https://git.sr.ht/~technomancy/fennel/tree/1.4.0/item/change...

Thanks for the correction! I had only used Lua, and thought Fennel had no runtime, so I assumed this was not possible.
Fennel has a form `assert-repl` which will drop into the REPL wherever, if the condition fails. For writing games you can launch the REPL in the game loop if a keyboard button is pressed. But what you can't do, that I know of, is interrupt arbitrary execution and get a Fennel REPL. You'd probably need a lua debugger of some sort for that. I'm not that familiar with that though.
Why can't you just put the equivalent of `(repl)` wherever you want to debug and drop into your REPL?
Short answer: I don’t know. That sounds like a good idea, but how would that access local variables in the caller (to inspect state)?

I remember the Lua C API exposes a lot of information, but I didn’t think it was accessible from scripts. Of course, it was a long time ago and I could have easily missed something at the time. Happy to be corrected!

Edit: you might also run into difficulties trying to redefine non-global functions to add the call to “repl”.