Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if you edit a file during compilation?

Sometimes compilation takes a long time, and I want to mess around with a file while it's compiling. Will saving the new file during compilation affect the build? Or is everything preloaded?

like image 217
Abs Avatar asked Jul 17 '13 16:07

Abs


People also ask

Does linking happen after compilation?

Linking − The linker is produces the final compilation output from the object files the compiler produced. This output can be a shared (or dynamic) library or an executable. It links the object files by replacing the undefined references with the correct addresses.

How does the compilation process work?

The compilation is a process of converting the source code into object code. It is done with the help of the compiler. The compiler checks the source code for the syntactical or structural errors, and if the source code is error-free, then it generates the object code.

What happens when you compile your program?

A compiler takes the recipe (code) for a new program (written in a high level language) and transforms this Code into a new language (Machine Language) that can be understood by the computer itself.

What is the difference between compilation and execution of a program?

compilation process converts source code into machine code while as execution means that machine code is ready for processing. In general sense compiling means converting source code into executable code.


1 Answers

I'm not sure this is a meaningful question: "is this the case with all compilers and languages?"

It's more meaningful to ask, For a given build system, can I edit source during a build?

With an ant build, it's clear that ant decides early (based on file timestamps) what to compile, but you don't know exactly when the compile task is started.

It's surely true that the compiler reads the source file just once, but you don't normally know when that happens.

The interesting use case is:

When I run sbt> ~ test, will sbt complete a test run while I'm editing code, or will it stop midstream to recompile?

I could see that it's useful to have a command option to determine whether edits abort a test run. You might want to see the test result, or maybe you're only interested in test results after a modification.

That's especially true if compile-and-test cycles seem interminable.

Here is the doc for testing. The doc for triggered execution says:

Monitoring is terminated when enter is pressed.

which could be construed to mean that monitoring is not suspended while the task executes.

like image 154
som-snytt Avatar answered Sep 28 '22 07:09

som-snytt