Skip to content

Source maps are unhelpful when used with transform macros #35

Open
@anko

Description

@anko

At the moment, the compiler cannot resolve source locations beyond where macros are called. It deliberately treats macros as black boxes, to insulate user macros from having to know anything about the location data stored on S-expression nodes.

Example: If someone has defined a macro hello and call it as (hello there a b c d), currently anything at all that hello call returns is just sourcemapped to the macro's call site.

This backfires majestically with transform macros.

Transform macros are just like user macros that take the whole program as their arguments and return whatever they feel like. The calls to them have no in-source location, and they are not necessarily location-data aware, so anything they emit (which is the whole program) is sourcemapped to… nowhere. You just get an empty source map. It sucks.


Some possibilities:

  • Let macros return whatever location data they want to—it's up to its author to decide if it's worth it for their specific one. Wait for transform macros to be replaced with reader macros (and have those return location data), so the effect of other macros not deciding to return location data is minimal.
  • Require all macros to be aware of location data and to emit location data on the nodes they return, and have the compiler enforce this. (This makes macros more complex to write.)

I like the first better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions