Revise.jl icon indicating copy to clipboard operation
Revise.jl copied to clipboard

includet and include don't actually do the same thing, and they should.

Open andyDoucette opened this issue 3 years ago • 8 comments

Issue

include() evaluates the contents of the input source in the global scope of the module you're in.

includet() evaluates the contents of the input source in the Main module only.

This is a major source of issues, as users like me will expect includet() to be a "tracking" version of include, otherwise the same.

I just spent 3 hours debugging an issue where if I included code using Genie (which used a different Module than Main), the included methods were nowhere to be found, but if I included the code directly from the REPL it worked fine. It was challenging to figure out what's going on.

Request

Can we change the behavior of includet to use the module it's in instead of Main all the time? Should be as easy as using @MODULE() I hope?

andyDoucette avatar May 16 '22 11:05 andyDoucette

I don't think there's a way for includet to stay a function and get its caller's scope. You can of course already use includet(@__MODULE__, "myfile.jl").

pfitzseb avatar May 17 '22 07:05 pfitzseb

If I can create a way, and make a pull request, would you merge it?

On Tue, May 17, 2022 at 3:51 PM Sebastian Pfitzner @.***> wrote:

I don't think there's a way for includet to stay a function and get its caller's scope. You can of course already use includet(@MODULE, "myfile.jl").

— Reply to this email directly, view it on GitHub https://github.com/timholy/Revise.jl/issues/682#issuecomment-1128533985, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEVLQ5SMM5X6QDS2AF3RPPTVKNFYXANCNFSM5WBF4JHA . You are receiving this because you authored the thread.Message ID: @.***>

andyDoucette avatar May 18 '22 01:05 andyDoucette

Impossible to say in the absence of the PR. But we merge PRs all the time here and in other packages.

Good PRs include a test and a clear motivation, and in this case the fact that you can use includet(@__MODULE__, "myfile.jl") seems like it undermines the need?

timholy avatar Jul 24 '22 13:07 timholy

Also LanguageServer doesn't track functions included in includet. Which I think affects every developer using includet but most of us just still keeps going even if such functionalities break and use find in the project!

As for the simplest MVP/fix is to change every includet to include and LanguageServer linkings will work, so LS navigations will work again.

This is a serious issue, I don't know if the two are connected, or I should just open a separate issue.

Sixzero avatar Apr 22 '23 10:04 Sixzero

That's funny because VSCode bundles Revise. So it knows about includet, and should be able to track things included that way.

timholy avatar Apr 22 '23 10:04 timholy

We could just make an @includet macro?

MasonProtter avatar Feb 16 '24 13:02 MasonProtter

Sure, but I still don't quite see the motivation for this.

pfitzseb avatar Feb 16 '24 13:02 pfitzseb