5 ms·
Only change is that you have to tell the compiler that 'undef-fn' exists but you don't have to provide an implementation. So, before all of that just do (d
by jhhh 4y ago
Only change is that you have to tell the compiler that 'undef-fn' exists but you don't have to provide an implementation. So, before all of that just do
(def undef-fn)
It should work after that.
- cyberbanjo 4y agoPre-declaring the undefined function does prevent the first of those exceptions. I guess it just feels weird to include Clojure here, because the CL experience is like it brings up an interactive debugger and asks if you wanna define the function now or abort.
- jhhh 4y agoRe-reading the original post I see what you mean now. But Clojure definitely fits the first part of the definition by compiling your methods instantly as you're writing them in the repl. For the second part I'm not aware of a prompt which would let you define a method in response to a missing function call. Might be an interesting feature.
- cyberbanjo 4y agoFor the second part: with restarts and conditions, CL pulls up an interactive debugger that asks if you would like to abort, continue/retry calling undefined or supply a definition now, amongst others. Evalutating this in CL (SBCL) (undef-fn) gives: Restarts: 0: [CONTINUE] Retry calling UNDEF-FN. 1: [USE-VALUE] Call specified function. 2: [RETURN-VALUE] Return specified values. 3: [RETURN-NOTHING] Return zero values. 4: [RETRY] Retry SLY interactive evaluation request. 5: [\*ABORT] Return to SLY's top level. 6: [ABORT] abort thread (#<THREAD "slynk-worker" RUNNING {100288C7E3}>) [... as well as a clipped stack trace ...] Pressing 1 will allow you to name an alternative function in a minibuffer prompt, 2 lets you set the return value of the undefined fn, etc.