You cannot literally run a sketch within a sketch, but you can definitely write something where that appears to be the case. This involves writing an alternative base class to PApplet, copying all the methods you want to support and instead making them draw to a PGraphics, and then loading the sketch code against this. It’s taking what @jeremydouglass talks about but also as much as possible making it function at “the level of code”.
This is loosely how PraxisLIVE actually works. And yes, handling events and libraries is interesting, but doable.
Add the ability to live code any sketch into the mix and it’s even more “fun” to build.
Of course, if you want multiple sketches on screen at once, you also need to reason how sketches merge. What does it mean for two sketches to both call background() for example?!
@GoToLoop Python mode would still have to handle the fact the library can’t literally do this, though. Might be easier to write the delegation method to fake this.