Skip to content

Preliminary support for include(mapexpr, file) #939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Conversation

timholy
Copy link
Owner

@timholy timholy commented Jul 24, 2025

In conjunction with CodeTracking.MapExprFile, this allows Revise to track
changes in files that are included with include(mapexpr, file). This
PR supports the implementation of revisions for such files, properly
applying the mapexpr transformation to the included file's
expressions.

What's missing:

  • Revise can't correctly populate the internal data structures needed to
    initiate mapexpr without help. The problem is that Revise only
    parses files that get edited, but discovering that file2.jl gets
    included from file1.jl via a mapexpr requires parsing file1.jl,
    which may not have been edited and therefore never scanned via Revise.
    The right way to fix this is in Julia itself, writing additional info
    to the package cache header. This will not land before Julia 1.13.
  • include(mapexpr, file) is well-suited to include the same file more
    than once with different mapexprs. While it hasn't been tested, this
    seems unlikely to work for now, and the anticipated problems stem all
    the way back to Julia itself (again, issues that should be fixed in
    the package cache header).

Package authors who want to use this in their packages can add a call to
Revise.parseall(@__MODULE__) in their __init__ function to
ensure that the mapexpr files are parsed and tracked by Revise.

Fixes #820, #634

Note this is built on #904 so the diff will be confusing unless you look at only the final commit.

serenity4 and others added 21 commits April 18, 2025 12:39
In conjunction with `CodeTracking.MapFile`, this allows Revise to track
changes in files that are included with `include(mapexpr, file)`. This
PR supports the implementation of revisions for such files, properly
applying the `mapexpr` transformation to the included file's
expressions.

What's missing:
- Revise can't correctly populate the internal data structures needed to
  initiate `mapexpr` without help. The problem is that Revise only
  parses files that get edited, but discovering that `file2.jl` gets
  included from `file1.jl` via a `mapexpr` requires parsing `file1.jl`,
  which may not have been edited and therefore never scanned via Revise.
  The right way to fix this is in Julia itself, writing additional info
  to the package cache header. This will not land before Julia 1.13.
- `include(mapexpr, file)` is well-suited to include the same file more
  than once with different `mapexpr`s. While it hasn't been tested, this
  seems unlikely to work for now, and the anticipated problems stem all
  the way back to Julia itself (again, issues that should be fixed in
  the package cache header).

Package authors who want to use this in their packages can add a call to
`Revise.parseall(@__MODULE__)` in their `__init__` function to
ensure that the `mapexpr` files are parsed and tracked by Revise.

Fixes #820, #634
@serenity4
Copy link
Collaborator

That appears much less intrusive than what I started at timholy/CodeTracking.jl#142 (comment), that's great!

IMHO the design remains somewhat less intuitive (treating the mapexpr-included files as a new kind of file), as opposed to an include-centric architecture (where we actually care about inclusions, not files directly - only indirectly). But given that for standard uses (like 99% of the time) we don't care about the distinction, I believe that keeping Revise file-centric is better and supporting mapexpr inclusions as a kind of file is a very good workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revise and DispatchDoctor
2 participants