=== Improving Common Lisp Infrastructure in FreeBSD Ports

Contact: Joe Mingrone <jrm@FreeBSD.org>

link:https://lisp-lang.org/[Common Lisp] (CL) is a general-purpose, multi-paradigm programming language first conceived in the early 1980s.
Although it predates many modern programming languages, it remains a viable option for many different projects.
One contemporary example is Grammarly, a widely used grammar engine reportedly implemented in CL and capable of processing over a thousand sentences per second.

The FreeBSD ports tree has provided CL support for many years.
The initial work was contributed by Henrik Motakef in 2003, and then enhanced and maintained by Jimmy Olgeni.
The infrastructure facilitated building and installing CL libraries using link:https://asdf.common-lisp.dev/[ASDF] so that multiple CL implementations could load compiled object code files (fasl) at run-time without conflicts.

However, many issues crept in over the years.
Support dwindled to only one CL implementation, link:https://www.sbcl.org/[SBCL], and users encountered longstanding bugs such as conflicting ASDF versions and write errors when loading libraries outside the ports tree.
Also, managing dependencies was cumbersome because most infrastructure code was included as part of the package:devel/cl-asdf[] port.

A long overdue update of the FreeBSD CL infrastructure was completed this quarter.
The primary outcome is that users can, once again, easily and reliably work with CL on FreeBSD.
For example, installing and loading the popular Alexandria library under SBCL requires only a few simple steps.

[source, shell]
----
% pkg install cl-alexandria-sbcl
% sbcl
* (asdf:load-system :alexandria)
----

Similar steps can be used to load libraries for the other two newly supported implementations: link:https://ccl.clozure.com/[CCL], and link:https://clisp.sourceforge.io/[CLISP].
Most users will likely prefer to work with the fasl ports, although there is no obligation to do so.
Because ASDF is now configured to fall back to its default caching mechanism of writing fasl to a cache under `${HOME}`, users can also install CL source ports without the associated fasl port or load CL sources from outside of the ports tree.

Other highlights of the update include:

- decoupling ASDF initialization from package:devel/cl-asdf[] by creating a dedicated port: package:devel/freebsd-cl-asdf-init[]
- creating `USES=cl`
- adding and updating various CL library ports for the three supported implementations
- updating and modernizing package:lang/ccl[] and package:lang/clisp[]

For details, refer to these commit logs:

- link:https://cgit.freebsd.org/ports/commit/?id=4c954c1522cbf4d05013caaf40c36458d82f1480[4c954c1522cbf4d05013caaf40c36458d82f1480]
- link:https://cgit.freebsd.org/ports/commit/?id=f6a75a8f9bf20dbf1e9a4d5bc171d58f595c1ec1[f6a75a8f9bf20dbf1e9a4d5bc171d58f595c1ec1]
- link:https://cgit.freebsd.org/ports/commit/?id=1d7c75a5cde6792b3872340edeaf8f278add291a[1d7c75a5cde6792b3872340edeaf8f278add291a]
- link:https://cgit.freebsd.org/ports/commit/?id=148251b431b8d972623bb3adaa5a71355f47ac26[148251b431b8d972623bb3adaa5a71355f47ac26]
- link:https://cgit.freebsd.org/ports/commit/?id=7f68336ed19be61027dfb7b461aacd056733eba4[7f68336ed19be61027dfb7b461aacd056733eba4]

The tentative plan is to add support for link:https://ecl.common-lisp.dev/[ECL] after an ASDF output translation issue is solved and to create ports for other CL libraries.
Feedback, testing, and contributions are welcome.

Sponsor: The FreeBSD Foundation
