JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.44k stars 5.46k forks source link

document REPL `ast_transforms` #37047

Open stevengj opened 4 years ago

stevengj commented 4 years ago

Julia 1.5 includes a REPL ast_transforms variable initially added for the softscope transformation (#33864) but expanded for use by other packages (#34626, #34778), that is starting to be used by other packages. It is currently being used by Revise (https://github.com/timholy/Revise.jl/pull/425), support will probably be added soon in IJulia (for the REPL.repl_ast_transforms defaults), and it might be used in the future by things like OhMyREPL.

We might consider documenting it somewhere. Maybe adding a slightly higher-level API, e.g.

REPL.current_ast_transforms() = isdefined(Base, :active_repl_backend) ? Base.active_repl_backend.ast_transforms : REPL.repl_ast_transforms
stevengj commented 4 years ago

Or maybe it should be part of repl.options (the REPL.Options struct)?

rfourquet commented 4 years ago

Maybe adding a slightly higher-level API, e.g.

REPL.current_ast_transforms() = isdefined(Base, :active_repl_backend) ? Base.active_repl_backend.ast_transforms : REPL.repl_ast_transforms

FWIW, this is almost exactly what SafeREPL uses.

stevengj commented 2 weeks ago

Note that there is the undocumented function REPL.Numbered.__current_ast_transforms(): https://github.com/JuliaLang/julia/blob/39f2ad1e941fd092b906d60e8d23c004e8ee5b7e/stdlib/REPL/src/REPL.jl#L1786