So my conclusion is that you don't like "define" = "set!" + allocation of global var if it doesn't exist. Right?
One approach to this, which in my experience leads to fewer odd bugs and makes the programmer's intention clearer is to do define it like define = "set!" if it exists in the current module, otherwise allocation of var in the current module. You then add special form to switch between modules, in black hole I simly call it "module":
Let module A contain a variable called test-a.
(In the repl:)
test-a => not defined (import A) test-a => refers to test-a in module A (define test-a 'lalala) test-a => refers to the test-a defined above, will evaluate to
'lalala
(module A) test-a => refers to test-a in module A (define test-a 'new-test-a-in-module-A) => redefines test-a in
module A
(module #f) => this means go back to the REPL pseudo-"module" test-a => refers to the test-a that has the value 'lalala
/Per