racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
456 stars 93 forks source link

Opening Pollen source in DrRacket causes no-arg call to root #555

Open otherjoel opened 2 years ago

otherjoel commented 2 years ago

See https://github.com/mbutterick/pollen/issues/268 — opening a Pollen source in DrRacket apparently causes the project-local root function to be called with no arguments. I know things can get blurry when dealing with DSLs but generally I would expect that DrRacket not run any of my projects’ code until I click the “Run” button.

This behavior in DrRacket is apparently new since 8.3.0.7 (I am using the Apr 5 snapshot of 8.4.0.8).

samth commented 2 years ago

Since this was a change between 8.3 and 8.4, it seems plausible this is about the new lexer and colorer protocols. Is it possible that pollen sets up a colorer that calls the root function?

otherjoel commented 2 years ago

I don’t know anything about the new lexer and colorer protocols. Pollen’s colorer/lexer code doesn’t look like it has changed for several years; do these new protocols necessitate changes that would cause problems if not implemented?

Is it possible that pollen sets up a colorer that calls the root function?

To a first approximation… it doesn’t look like it? The colorer does use pollen/setup which in turn will try to find a pollen.rkt file in the same folder or parent folder and get values out of the setup submodule of such a file if one exists. But that should not cause this behavior.

rfindler commented 2 years ago

I added a comment to https://github.com/mbutterick/pollen/issues/268.

rfindler commented 2 years ago

It looks like the problem has to do with the way that DrRacket initializes the interactions window before running the first program. DrRacket would like to get an initial namespace set up so that when one opens a file and types something into the interactions window, some reasonable response comes back from that. While some reasonable people seem to think that this idea is just a plain bad one and we could simply disable it, I found it useful to have a REPL ready to go when opening a new tab in DrRacket.

Another idea might be to have languages opt in to this and, when a language doesn't opt in to this behavior, the initial interactions window would have a message saying something (probably with better phrasing) along the lines of "click Run first if you want an interactions window".

otherjoel commented 2 years ago

I found it useful to have a REPL ready to go when opening a new tab in DrRacket.

Then, at the very least, I would strongly request that this be a preferences setting. I guess I would also suggest that it be off by default since it can result in unintended side-effects and even broken behavior with some languages.

rfindler commented 2 years ago

Thanks, @otherjoel . I think the two suggestions currently on the table (disabling it and having it be opt-in at the language level so it applies only to languages that don't have such side effects) are better than a preferences setting. There are already far too many preferences settings in DrRacket and it is hard to find stuff.

rfindler commented 2 years ago

Also, just in case it wasn't clear, I pushed a change to DrRacket that will be included in the upcoming release that disables this for Pollen.

otherjoel commented 2 years ago

There are already far too many preferences settings in DrRacket and it is hard to find stuff.

I fully agree with this. Making it opt-in at the lang level would be best, and would be consistent with other ways in which languages can cooperate with DrRacket to enable certain features.

otherjoel commented 2 years ago

Also, just in case it wasn't clear, I pushed a change to DrRacket that will be included in the upcoming release that disables this for Pollen.

Thanks. Just want to point out that Pollen includes a few languages which don’t appear to be covered by that commit.

rfindler commented 2 years ago

Also, just in case it wasn't clear, I pushed a change to DrRacket that will be included in the upcoming release that disables this for Pollen.

Thanks. Just want to point out that Pollen includes a few languages which don’t appear to be covered by that commit.

Thank you. I've tried again.

rfindler commented 2 years ago

This behavior in DrRacket is apparently new since 8.3.0.7 (I am using the Apr 5 snapshot of 8.4.0.8).

After a little investigation, I think that what's new is a UI improvement that makes this issue easier to trip across, not the issue itself. The initialization in the REPL code hasn't changed in 6 years (and the change 6 years ago changes how it happens, not that it runs an empty program in the given language to get an initial environment).

racket-discourse-github-bot commented 1 year ago

This issue has been mentioned on Racket Discussions. There might be relevant details there:

https://racket.discourse.group/t/racket-version-8-7-is-now-available/1478/8