Packages in LISP
Packages are a central mechanism in which a Common Lisp is used in managing different sets of names and avoiding name collisions that may occur if multiple files contain the same variables or functions with the same name. Understanding the package system to correctly split our code across multiple files and then load them together as one program. Packages facilitate Common Lisp to divide namespace.
A package is a Lisp object like a number, a list, or a character string. In particular, the type package is defined. A package can be the value of a symbol, given as an argument to a function, returned by a function, etc.
Syntax for Creating a LISP Package:
(defpackage :package-name (:use :Function1 ...) (:export :Geek1 :Geek2 ...) )
- defpackage: This package is used to create a user to define the package.
- package-name: It defines the name of the package created by the user.
- :use: This Function is used in the code by the package.
- :export: represents an external package.
make-package package-name &key :StudentsNames :use
make-package is used in creating user-defined packages.
For Deleting a LISP package we use the following syntax.
- delete-package: It allows us to delete a user-defined package.