In C, to make sure we don't re-include headers that are included we use the following structure:
#ifndef UTILS
#define UTILS
#include "my_utils.h"
#endif
I've broken my Lisp program into separate files; multiple files sometimes use the same file (e.g., my_utilities is used by multiple files). When I run the program, I get warnings that I am redefining things (calling load
of the same file multiple times).
This would be fixed by doing something similar to #ifndef
in C. What is the Common Lisp equivalent or standard method of doing this?
I am fairly new to Lisp. Let me know if there are best practices (perhaps, a different method of structuring my programs?) that I am missing.
The direct analogue of preprocessor conditions like #if
in C is the
#+
read-time conditionalization facility.
To avoid multiple loading of a file, you can either use the standard
(but deprecated)
provide
/require
facility,
or an add-on system like ASDF.