Can I Unlock a Function in Common Lisp

I study defclassand defmethodand defgeneric, therefore, I did defclass, called savings-account, with the element balance.

I created defun(shown below) to start changing the balance value, but it is not complete.

(defun balance (account)
  (slot-value account 'balance))

Then I decided to go with defgeneric(below).

(defgeneric balance (account))

But when I started defgeneric, I got this error:

BALANCE already calls a regular function or macro.

Is there a way to easily and easily turn off balance, so I don’t need to restart an Emacs session?

+4
source share
2 answers

Any self-respecting Lisp will suggest you restart the error to change the definition.

SLIME Clozure CL:

The function BALANCE is defined as something other than a generic function.
   [Condition of type CCL::SIMPLE-PROGRAM-ERROR]

Restarts:
 0: [CONTINUE] Try to remove any global non-generic function or macro definition.
 1: [RETRY] Retry SLIME REPL evaluation request.
 2: [*ABORT] Return to SLIME top level.
 3: [ABORT-BREAK] Reset this thread
 4: [ABORT] Kill this thread

CONTINUE, 0 , return.

Xach, SLIME, c-c c-u, SLIME-UNDEFINE-FUNCTION.

+2

( defun defgeneric) fmakunbound.

+6

Source: https://habr.com/ru/post/1523777/


All Articles