Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Zero to Common Lisp
Search
Sean Bryant
December 05, 2011
Programming
4
310
Zero to Common Lisp
How common lisp projects are put together.
Sean Bryant
December 05, 2011
Tweet
Share
More Decks by Sean Bryant
See All by Sean Bryant
NST
sbryant
2
190
Clubot
sbryant
4
260
Other Decks in Programming
See All in Programming
Let's learn code review
riofujimon
2
570
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
300
Scalable Customer Journey Orchestration (CJO)
lewuathe
0
410
雑に思考を整理する技術と効能
konifar
62
30k
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
180
Goのmultiple errorsについて (2024年4月版)
syumai
4
1.1k
PostmanでAPIの動作確認が楽になった話
h455h1
0
180
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
560
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
27
8.5k
Elm Form Validation
bkuhlmann
0
510
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
420
Apache Hive 4 on Treasure Data
ryukobayashi
1
410
Featured
See All Featured
Teambox: Starting and Learning
jrom
128
8.4k
Clear Off the Table
cherdarchuk
85
310k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
33
6k
4 Signs Your Business is Dying
shpigford
176
21k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
79
43k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
A better future with KSS
kneath
231
16k
RailsConf 2023
tenderlove
8
550
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
275
13k
Why Our Code Smells
bkeepers
PRO
331
56k
Raft: Consensus for Rubyists
vanstee
133
6.3k
Transcript
Zero To Common Lisp How Common Lisp projects are put
together.
About Me.
About Me. •Programmer at Vitrue.
About Me. •Programmer at Vitrue. •One of the resident “lisp
dudes”
About Me. •Programmer at Vitrue. •One of the resident “lisp
dudes” •A new lisper
About Me. •Programmer at Vitrue. •One of the resident “lisp
dudes” •A new lisper •First lisp presentation
Going to Talk About:
Going to Talk About: Files, Images and Packages
Going to Talk About: Files, Images and Packages CLOS -
Just the basics.
Going to Talk About: Files, Images and Packages CLOS -
Just the basics. Asdf & Quicklisp.
Going to Talk About: Files, Images and Packages CLOS -
Just the basics. Asdf & Quicklisp. Quickproject
Files Lisp doesn’t care about your files. Maybe it cares
a little. ASDF cares. More on that later.
Packages Mapping of symbols *package* - Current package. Symbol Import/
Export interface No global package Common-Lisp-User Supports Inheritance Using a package Importing Shadowing
(defpackage :clcss (:use :cl) (:export :read-css)) (in-package :clcss)
None
Images
Images Dump/load frozen state
Images Dump/load frozen state Distribute a “native” app.
Images Dump/load frozen state Distribute a “native” app. Always working
with one
Images Dump/load frozen state Distribute a “native” app. Always working
with one Similar to Smalltalk
Images Dump/load frozen state Distribute a “native” app. Always working
with one Similar to Smalltalk FFI is a pain the ass.
CLOS The worst introduction ever.
CLOS Common Lisp Object System The worst introduction ever.
CLOS Common Lisp Object System Objects do not have methods
The worst introduction ever.
CLOS Common Lisp Object System Objects do not have methods
Instead Lisp has generic functions The worst introduction ever.
CLOS Common Lisp Object System Objects do not have methods
Instead Lisp has generic functions defgeneric The worst introduction ever.
CLOS Common Lisp Object System Objects do not have methods
Instead Lisp has generic functions defgeneric declares options and arguments for methods The worst introduction ever.
CLOS Common Lisp Object System Objects do not have methods
Instead Lisp has generic functions defgeneric declares options and arguments for methods defmethod The worst introduction ever.
(defclass my-class () ((my-slot :initform t :accessor my-slot :documentation “A
simple slot.”)) (:documentation “A simple class”))
defmethod
defmethod specializes generic function based on type of object
defmethod specializes generic function based on type of object not
restricted a single type multi-methods
defmethod specializes generic function based on type of object not
restricted a single type multi-methods eql specializers, specialize to particular instances of objects.
defmethod specializes generic function based on type of object not
restricted a single type multi-methods eql specializers, specialize to particular instances of objects. combinators :before, :around, :after allow for hooking into method calls.
(defmethod initialize-instance :after ((o my-class) &key) ...) Custom constructor (defmethod
slot->nil ((o my-class)) (setf (my-slot o) nil)) A simple method. method combinator
ASDF Almost a standard*
ASDF Another System Definition Facility Almost a standard*
ASDF Another System Definition Facility Organize your code, through files...
Almost a standard*
ASDF Another System Definition Facility Organize your code, through files...
Understanding the object model is key. Almost a standard*
ASDF Another System Definition Facility Organize your code, through files...
Understanding the object model is key. Components Almost a standard*
ASDF Another System Definition Facility Organize your code, through files...
Understanding the object model is key. Components Operations Almost a standard*
ASDF Another System Definition Facility Organize your code, through files...
Understanding the object model is key. Components Operations Extensible Almost a standard*
(defsystem #:clcss :name "clcss" :version "0.0.0" :depends-on (:cl-ppcre) :in-order-to ((test-op
(load-op clcss-tests))) :components ((:module "src" :components ((:file "package") (:file "clcss" :depends-on ("package")))))) (defmethod perform ((o asdf:test-op) (c (eql (asdf:find-system :clcss)))) (funcall (intern (symbol-name :run-all) :clcss-tests))) Example ASD
defsystem form
defsystem form Usual meta-data :author :description :version :maintainer
defsystem form Usual meta-data :author :description :version :maintainer :perform -
stub out custom functionality
defsystem form Usual meta-data :author :description :version :maintainer :perform -
stub out custom functionality Components root of all other components.
defsystem form Usual meta-data :author :description :version :maintainer :perform -
stub out custom functionality Components root of all other components. :serial :depends-on :in-order to
defsystem form Usual meta-data :author :description :version :maintainer :perform -
stub out custom functionality Components root of all other components. :serial :depends-on :in-order to Grammar is short, easy to reference.
Components
Components Modules - Directories.
Components Modules - Directories. Files Defaults to cl-source-file Static files
- README, ChangeLog etc.
Components Modules - Directories. Files Defaults to cl-source-file Static files
- README, ChangeLog etc. Systems*
Components Modules - Directories. Files Defaults to cl-source-file Static files
- README, ChangeLog etc. Systems* *Systems are actually special modules
Operations load-op compile-op load-source-op test-op
Perform (defgeneric perform (operation component)) Now all together! Because it’s
CLOS we can change it. Test operations are the most common.
(defsystem #:clcss :name "clcss" :version "0.0.0" :depends-on (:cl-ppcre) :in-order-to ((test-op
(load-op clcss-tests))) :components ((:module "src" :components ((:file "package") (:file "clcss" :depends-on ("package")))))) (defmethod perform ((o asdf:test-op) (c (eql (asdf:find-system :clcss)))) (funcall (intern (symbol-name :run-all) :clcss-tests)))
ASDF Usage (asdf:oos ‘asdf:load-op :clcss) operate on system (asdf:load-system :clcss)
A short-cut to oos.
The ASDF Source Registry How ASDF finds your systems.
If you put software in ~/ .local/share/common-lisp/source/ You’re done.
Most likely you don’t. Shove configuration files in: ~/.config/common-lisp/source-registry.conf.d/ Or
set CL_SOURCE_REGISTRY Files end in .conf by convention Examples directives (:directory “/path/to/source/”) (:tree “/path/to/tree/of/sources/”)
Quicklisp It’s your gem, pip, lenin, cabal... Speaks ASDF ASDF
+ Quicklisp == Bundler-ish ASDF + Quicklisp == pip + requirements.txt
Using QL (ql:quickload :clcss) It really is that easy.
Starting out
Quickproject From the guy who brought you quicklisp Bare-bones project
skeleton. Great starting point. https:/ /github.com/xach/quickproject
Quickproject (quickproject:make-project #p"src/screenscraper/" :depends-on '(cl-ppcre drakma closure-html))
Simple things don’t need to be projects. (load #p”/path/to/script”) Sometimes
is all you want.
Q&A You can find me here: @sean_bryant