Question

So I was writing my own function and I called it make-list and I got this from debugger:

   The function MAKE-LIST is predefined in Clozure CL.
   [Condition of type SIMPLE-ERROR]

   Restarts:
   0: [CONTINUE] Replace the definition of MAKE-LIST.

Fine, but what if I had accidentally chosen option 0?? Would my compiler be broken and forever have the wrong definition of an internal function, as I would have replaced it?

Was it helpful?

Solution

Only your currently running image would be broken, in which case you can restart CCL to restore it.

The only way to do permanent damage is to save the image, and chose to overwrite the original image file.

OTHER TIPS

Many Lisp systems are written in Lisp themselves.

Clozure CL is such an example. Clozure CL is written in Clozure CL (with some C and assembler). Clozure CL can compile itself.

Thus many/most Common Lisp functions in Clozure CL are written in Clozure CL. So it needs some kind of a switch, where it allows to define or redefine built-in functionality. So there is definitely a way to edit the implementation's source code and change things. It would be best that your definitions are 'correct', so that the functioning of the Lisp system is not compromised. Keep in mind that redefinitions typically do not have an effect on inlined functions or on already expanded macros.

Now, if we as typical programmers use Clozure CL, some packages are protected and redefining the symbols are not allowed and an error is signaled. But you can continue and then change internal functions. As always in many Common Lisp, they are wide open for changes, but this comes with the responsibility for you as the programmer to do the right thing.

If you change a Lisp-internal function, there a some ways to leave permanent damage:

  • saving an image and using that later

  • using it to recompile CCL itself or parts of it

  • you could compile a file and somehow the generated code could be different than with the original compiler

  • you could compile a file and somehow the generated code includes an inlined version of the changed Lisp function

if one loads such a file, it could be automatically via some init file, it contains the changes and the changed code will be a part of the then currently running Lisp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top