home/ atoms/ p5live-recompile-scope-edit-wont-take

A P5LIVE edit that won't take effect is usually a recompile-scope issue — class-method or global-state edits do not hot-swap live instances

P5LIVE recompiles as you type, but the recompile scope has limits that look like bugs. Editing a class method does not update objects already instantiated — old instances keep running the old code until re-emitted. Editing a global variable or a setup()-level statement forces a hardCompile that resets sketch state rather than smoothly patching it. The symptom is an edit that seems ignored, or a sketch that unexpectedly restarts. The fix is to keep live-evolving state inside draw() (not globals), and to hardCompile or re-emit instances after class edits.

Examples

Change a method on a particle class mid-run — existing particles keep the old behavior; only newly spawned ones use the edit. Move mutable state from a global into draw() so edits patch live without a resetting hardCompile.

Assessment

A P5LIVE sketch edit appears to be ignored while the sketch keeps running. Give two structural causes and, for each, the change that makes future edits take effect live.

“editing a `class` method (old instances keep old code), or a global/`setup` change resetting state”
context/ · L5-debug/p5live.md · chunk 1