P5LIVE softCompile only replaces changed functions, leaving global-variable or setup edits to trigger a full hardCompile
P5LIVE performs two kinds of recompile. A softCompile swaps only the edited function body while keeping sketch state alive — useful for editing code inside draw() without visual interruption. A hardCompile (full sketch restart) is triggered when you edit a global variable, setup(), or preload(). The key gotcha: any live-evolving state that lives in a global (counters, particle arrays) will be reset by a hardCompile. Keep mutable performance state inside draw(), not at the global scope, to avoid unintended resets mid-set. Running an unchanged sketch forces a hardCompile and is the sanctioned way to clear the canvas or reset instances without touching the code.
Examples
Move a particle array from a global let particles = [] into a variable scoped inside draw(), or use a flag to reinitialise only when wanted. Editing a class body leaves old instances on the old code until the next hardCompile or re-emit.
Assessment
Given a sketch whose evolving state lives in a global variable, predict what happens when the performer edits a line of setup(). Then propose a refactor that keeps the state alive across normal edits.