Skip to content

Easier macro debugging #741

@cwebber

Description

@cwebber

I'm currently writing a larger program in Hy. Coding in Hy is a dream.. debugging is a headache. The reasons are simple: line numbers are lost in the context of any macros, and of course plenty of things in Hy are macros. In one of @paultag's demos he shows that using pdb with Hy works surprisingly great, but of course this presentation didn't show anything wrapped in a macro, in which case all information and context is lost. You're debugging blind: you still have other senses, but sight of line numbers isn't one of them. Similarly with tracebacks.

The problem is that have no idea what will come out of a macro, and even if we did, we lose track of it by the time it comes around to the AST being generated.

Is this unsolvable? Maybe. But other languages have done better:

  • Emacs Lisp and Racket both allow for stepping through macros. Many lisps do not provide it, and both of these do something clever to provide it.
  • Guile and Racket both have tracing, and Racket even has macro tracing (whatever that is).
  • Probably if we had something like define-syntax in scheme and encouraged users to use that, it would be easier to infer some of these structures.

Is it impossible for us to do this? I don't know... I think that if emacs lisp can have a sense of where things are, probably we can. At the very least, once we build AST, we might be able to use some information from macro expansion (or at least, certain common patterns of macro expansion using some sort of define-syntax system) to be able to debug things.

The current state of things is pretty sorry anyway. I'd like them to become better. Feel free to use this thread to dump ideas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions