eev
demoWe are making a new common lisp source package system using the asdf de facto extension supported and used by every modern common lisp compiler (common lisp has lots of compilers). Normally you keep common lisp code like this so you can asdf:load-system
it conveniently later on.
Given lisp’s interactive nature, instead of writing some mysterious big source file, compiling and loading it, Eduardo pioneered his concept of software as interactive logs starting in the 90s.
Instead of having separate but concurrent experimentation and big-actual-source writing steps in programming, the source should be literally the log of our continuous experiments as they started coming together properly.
I full-throatedly support Eduardo’s eev
useage and knowledge-sharing project and have hence included its (from common lisp’s perspective, invisible) architecture in the intended manner.
Remember we just tap <F8>
through source blocks in eev
mode in emacs. Conceivably you could copy or otherwise run source manually, but I expect you to be doing it in a convenient and powerfully literate way.
#|
(eepitch-sbcl)
(eepitch-kill)
(eepitch-sbcl)
|#
(ensure-directories-exist #p"~/common-lisp/system-example/")
~/common-lisp/
is one of two default user level system directories used by asdf
- another system definition facility for common lisp. Now we created (ensured) our new system directory, ~/common-lisp/system-example/
exists.
(with-open-file (*standard-output*
#p"~/common-lisp/system-example/system-example.asd"
:direction :output
:if-exists :Supersede
:if-does-not-exist :create)
(format t "
(defsystem :system-example
:class :package-inferred-system)
"))
some people (specifically Nicholas Martyanoff) like to do tonnes of manual work and fiddling with their systems. However my practical example captures my desire to do basically nothing myself, and having the good-old-fashion-a-i thinking machine that is the ASDF software figure out what to do for me for me. If you did not opt-in to :class :package-inferred-system
you have to write a whole bunch of stuff by hand. Fortunately, we did write :class :package-inferred-system
and are hence done. Good work everybody.
:system-example
system and the nature of eev
(with-open-file (*standard-output*
#p"~/common-lisp/system-example/hello.lisp"
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(format t
"
;;; I generate the interactive-eepitch comment by typing
;;; 'sbcl M-T' (sbcl alt-shift-t) inside the block comment:
#|
(eepitch-sbcl)
(eepitch-kill)
(eepitch-sbcl)
|#
;;; This lets people in eev step through by pressing `<F8>`
;;; over and over have lisp start in the other half of their
;;; screen and play out what is happening bit by bit.
;;; In :class :package-inferred-system, the only piece of
;;; work we do is that every lisp source file begins with a
;;; package definition (otherwise, other people put these
;;; package definitions somewhere else and manage their
;;; definitions being loaded themselves)
(uiop:define-package :system-example/hello
(:export #:message))
;; Going into the package is just the lisp meaning of going
;;;into the package here
(in-package :system-example/hello)
;; Let's make message be a closure.
(setf (symbol-function 'message)
(let ((message-text '|hello world|))
(lambda ()
(princ message-text)
(terpri))))
"))
and we are done! So while in eev-mode
we were picking and choosing what lines to run and tapping <F8>
(default moves to the next line after running a line), but now that we completely wrote a new system with one package, we can load the package using modern common lisp compilers’ asdf
implementations:
(in-package :cl-user) ; default user package.
(asdf:load-system :system-example/hello)
(system-example/hello:message)
You might need to ‘register new packages and try again’ by choosing a number from a menu if your lisp image pre-existed the package.
(eev
concerns itself with interactive useage while writing the source- it leaves loading the lisp system to the lisp compilers’ asdf
as seen here).
This is every single thing to know about writing systems of packages in common lisp. In fact, you can run the code above in emacs eev
or otherwise to make a system with your own first package. Everything else is just special purpose bells and whistles.
If you otherwise know lisp, you are completely ready to use the de facto substandard asdf
that modern compilers all integrate for loading from asdf systems.
I suggest sharing and refering to this article as a straightforward statement of how to make and use systems of packages with common lisp. You have my blessing to do so anywhere and everywhere that occurs to you.
Hope to hear from you on the Mastodon about this!
screwlisp proposes kittens