FluxML / MacroTools.jl

MacroTools provides a library of tools for working with Julia code and expressions.
https://fluxml.ai/MacroTools.jl/stable/
Other
308 stars 77 forks source link

rmlines would be more useful if it worked recursively #171

Open MarkNahabedian opened 2 years ago

MarkNahabedian commented 2 years ago

rmlines would be more useful it it worked recursively.

rmlines(Meta.parse("""
begin
   begin
      begin
end
end
end"""))
quote
    begin
        #= none:3 =#
        begin
            #= none:4 =#
        end
    end
end

Yes, one could use postwalk, but I don't think one should have to.

Also, why isn't postwalk exported?

At the very least, the documentation should manage expectations by saying that it doesn'[t work recursively and suggesting the use of postwalk.

cstjean commented 2 years ago

The docs seem fine to me? If you feel it can be better written, make a PR.

I can't speak for Mike, but presumably having these functions be non-recursive by default means that you could chain them inside of a single postwalk, which is more efficient than doing N postwalks, so I would keep the current design.

Also, why isn't postwalk exported?

I wouldn't mind exporting them, but... 🤷 Does anyone else have feelings either way?