When building up some functions, I can make some mistakes. When this happens, I click RUN and have to re-enter all of the previous definitions and the new attempt.
Is there some way to “undefine” the previous (define (func args ...) body) and just keep going?
First of all, the behaviour is by design.
Variables can not be mutated outside a module.
This gives the optimizer a chance to, among other
things, inline various things.
See http://docs.racket-lang.org/guide/module-set.html
for a detailed explanation.
If you need to modify something inside a module,
the standard way of doing it, is to use a parameter.
Here is a quick hack (and I mean hack) that abuses parameters
to make redefinitions possible.
To declare a function to be redefineable use
redefineable.In this example a function
foois declared to be redefineable.Now run the program, and in the interaction windows, we can now do as follow: