compiler-explorer / compiler-explorer

Run compilers interactively from your web browser and interact with the assembly
https://godbolt.org/
BSD 2-Clause "Simplified" License
15.66k stars 1.67k forks source link

[REQUEST]: Please preserve compilers when changing language if possible #3748

Open zygoloid opened 2 years ago

zygoloid commented 2 years ago

Is your feature request related to a problem? Please describe

When changing input language between C and C++, all compiler windows are reset to show GCC trunk output. This happens if I'm trying to compare the behavior in C and C++, or if I start entering code and configuring the compilers before noticing that the wrong language is selected for my source view.

Describe the solution you'd like

If a compiler with the same name exists in the new language, switch the window to use that compiler rather than resetting it to the default for the language. Try to keep the names of registered compilers for C and C++ aligned so that this works.

Describe alternatives you've considered

Another option would be to remember a set of default compilers for each language. However, I don't think that's likely to be workable in the case where multiple compilers are open for a single source view, and wouldn't provide the experience that I'm looking for.

Another approach that would allow me to solve the same problem in a different way would be to add functionality to save the current view configuration (which compilers are open, what their flags are, how windows are laid out, and so on), and permit loading a new view while retaining the current input text. That seems problematic because the source and destination configuration might have a different number of source views open.

Additional context

Not applicable

mattgodbolt commented 2 years ago

Thanks! It makes a lot of sense. We'll have to think: we don't have any context about what "the same" compiler is; but I guess we can use a heuristic based on the path or something?

partouf commented 2 years ago

[Nevermind, this is about compilers]

pmor13 commented 2 years ago

@zygoloid To remind: many C/C++ compilers allow to specify explicitly the language for the input files. Example: https://godbolt.org/z/s3YdoTY5T.