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
WebComponentsで フレームワークを1ページに共存させる
webuilder240
0
150
PHPでOfficeファイルを取り扱う! PHP Officeライブラリを プロダクトに組み込んだ話
hirobe1999
0
830
phpunit/php-code-coverageって何をしてるんだ #phperkaigi
o0h
PRO
2
210
Enhancing Applications with Accessibility API
kishikawakatsumi
3
850
Parallel Socket Communication in Swift
s_shimotori
0
210
MySQL のインデックスの種類をおさらいしよう! / overviewing indexes in MySQL
okashoi
0
170
上手な探索的テストとその上達方法について
matsu802
4
650
WasmOS: Wasmを実行する自作Microkernel
riru
0
370
ファイル先頭の use の意味、説明できますか? 〜PHP の namespace と autoloading の関係を正しく理解しよう〜 / namespace and autoloading in php
okashoi
2
470
設計の知識と技能で駆動するソフトウェア開発
masuda220
PRO
18
10k
Kotlinを用いたDSL的な設計手法と使用上の注意
kohii00
3
530
Migrating to Signals: A Practical Workshop
manfredsteyer
PRO
0
280
Featured
See All Featured
How GitHub (no longer) Works
holman
301
140k
The Brand Is Dead. Long Live the Brand.
mthomps
48
21k
What’s in a name? Adding method to the madness
productmarketing
PRO
14
2.6k
Into the Great Unknown - MozCon
thekraken
10
830
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
57
14k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
The Cost Of JavaScript in 2023
addyosmani
13
3.7k
JazzCon 2018 Closing Keynote - Leadership for the Reluctant Leader
reverentgeek
178
11k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
225
51k
How to name files
jennybc
62
92k
The Pragmatic Product Professional
lauravandoore
24
5.7k
We Have a Design System, Now What?
morganepeng
42
6.7k
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