Skip to content

Commit 03f7d31

Browse files
committed
doc: update snapshot
1 parent 6002d21 commit 03f7d31

36 files changed

+875
-45
lines changed

src/Index.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
🚧 사이트 공사중입니다.
44

5+
LISP(`LIS`t `P`rocessing)
6+
7+
- **[간단하게 살펴보기(Learn X in Y minutes)](https://learnxinyminutes.com/ko/common-lisp/)**
8+
9+
10+
- [CADR LISP Machine](https://metebalci.com/blog/cadr-lisp-machine-and-cadr-processor/)
11+
![CADR LISP Machine](res/mit-lisp-machine-3478-72lg.jpg)
12+
13+
14+
15+
16+
## REPL
17+
18+
REPL: 읽고(`R`ead) 평가하고(`E`val) 출력(`P`rint)을 반복(`L`oop)
19+
20+
``` lisp
21+
* (load "hello.lisp")
22+
```
23+
524
## Ref
625

7-
- [wiki: Common Lisp](https://en.wikipedia.org/wiki/Common_Lisp)
26+
- [wiki: Common Lisp](https://en.wikipedia.org/wiki/Common_Lisp)

src/SUMMARY.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@
4444
- [gensym](./advanced/gensym.md)
4545
- [디버그](./advanced/debug.md)
4646
- [asdf](./advanced/asdf.md)
47+
- [FFI(Foreign Function Interface)](./advanced/ffi.md)
48+
- [test](./advanced/test.md)
49+
- [regexp](./advanced/regexp.md)
50+
- [network](./advanced/network.md)
4751

4852
# Common Lisp Object System
4953

5054
- [CLOS](./clos/clos.md)
5155

52-
# 박물관
53-
54-
- [커먼리스프 역사](./museum/history.md)
55-
- [배포판](./museum/implementation.md)
56-
- [인물들](./museum/people/people.md)
57-
- [John McCarthy](./museum/people/john-mccarthy.md)
58-
5956
# 어둠의 길
6057

6158
- [리더매크로](./darkside/reader-macro.md)
@@ -71,6 +68,17 @@
7168

7269
- [Quicklisp](./library/quicklisp.md)
7370

71+
# 박물관
72+
73+
- [커먼리스프 역사](./museum/history.md)
74+
- [배포판](./museum/implementation.md)
75+
- [인물들](./museum/people/people.md)
76+
- [John McCarthy](./museum/people/john-mccarthy.md)
77+
78+
# Lisp 만들기
79+
80+
- [Lisp 만들기](./making/writing-lisp.md)
81+
7482
# 참고
7583

7684
- [참고자료](./reference/reference.md)

src/advanced/asdf.md

Lines changed: 184 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,184 @@
1-
# asdf
1+
# ASDF
2+
3+
| 버전 | |
4+
| ---- | ------------------------------------------------------- |
5+
| 3 | released May 15th 2013. UIOP is part of ASDF 3 |
6+
| 2 | François-René Rideau's ASDF 2 (released May 31st 2010). |
7+
| 1 | Daniel Barlow's ASDF (created on August 1st 2001) |
8+
9+
10+
- [ASDF](https://asdf.common-lisp.dev/)
11+
- `A`nother `S`ystem `D`efinition `F`acility
12+
- .asd 파일
13+
- lisp 프로젝트 관리 파일
14+
- `A`SDF `s`ystem `d`efinition
15+
16+
17+
18+
| 경로 | 설명 |
19+
| ---------------------------------- | ------------------------------------------- |
20+
| ~/common-lisp/ | Common Lisp 소프트웨어 설치 기본 위치(권장) |
21+
| ~/.local/share/common-lisp/source/ | |
22+
23+
- 크게 다음 2파트로 나뉩니다.
24+
- `asdf/defsystem`: 패키지정의
25+
- `uiop`: 유틸리티
26+
27+
28+
29+
``` lisp
30+
;; file: helloworld/helloworld.asdf
31+
32+
(asdf:defsystem "helloworld"
33+
34+
:build-operation program-op
35+
:build-pathname "helloworld"
36+
:entry-point "helloworld::main"
37+
38+
:depends-on ()
39+
40+
:components
41+
((:static-file "README.md")
42+
(:module "src"
43+
:depends-on ()
44+
:components
45+
((:file "package")
46+
(:file "hello" :depends-on ("package"))))))
47+
```
48+
49+
``` lisp
50+
;; file: helloworld/src/package.lisp
51+
52+
(defpackage :helloworld
53+
(:use :common-lisp))
54+
(in-package :helloworld)
55+
```
56+
57+
``` lisp
58+
;; file: helloworld/src/hello.lisp
59+
60+
(in-package :helloworld)
61+
62+
(defun -main (args)
63+
(princ args))
64+
65+
(defun main ()
66+
(-main (uiop:command-line-arguments)))
67+
```
68+
69+
## .asd
70+
71+
시스템이 있고 그 다음 패키지
72+
73+
- #P"..." : Common Lisp에서 pathname 리터럴을 의미합니다.
74+
- 예: #P"/home/user/code" → (make-pathname :directory '(:absolute "home" "user" "code"))
75+
- 해당 경로가 실제 존재하는지는 확인하지 않음
76+
- truename : Pathname 리턴
77+
- (truename "D:/@lisp/my-lisp-systems") ;; => #P"D:/@lisp/my-lisp-systems/"
78+
- 경로가 존재하지 않으면 에러
79+
80+
``` lisp
81+
(require 'asdf) ; => ("ASDF" "asdf" "UIOP" "uiop")
82+
83+
;;; 버전 확인
84+
(asdf:asdf-version) ; => "3.3.1"
85+
86+
;;; 시스템 폴더를 센트럴 레지스트리에 추가
87+
(pushnew (truename "D:/@lisp/my-lisp-systems/helloworld") asdf:*central-registry*)
88+
89+
;;; 시스템 로드. helloworld.asd 파일을 읽어들임
90+
(asdf:load-system :helloworld)
91+
92+
;;; 시스템 로드 ( 강제 )
93+
(asdf:load-system :helloworld :force t)
94+
95+
96+
(asdf:make :helloworld)
97+
98+
99+
(asdf:load-system :helloworld)
100+
(asdf:compile-system :helloworld)
101+
```
102+
103+
104+
105+
.fasl - `Fas`t `L`oading (or Loadable) file
106+
(asdf:operate 'asdf:compile-bundle-op :helloworld :verbose t)
107+
108+
| | |
109+
| ---------------------------- | ----------------------------------------------------------------------------------------------- |
110+
| program-op | (create a standalone application, which we will see below), etc. |
111+
| compile-bundle-op | (create a single fasl for the entire system, for delivery), |
112+
| monolithic-compile-bundle-op | (create a single fasl for the entire system and all its transitive dependencies, for delivery), |
113+
| compile-op | (ensure the system is compiled, without necessarily loading all of it, or any bit of it), |
114+
| image-op | (create a development image with this system already loaded, for fast startup), |
115+
| load-source-op | (load the system from source without compiling), |
116+
117+
compile-bundle-op필요한 각 시스템에 대해 하나의 FASL 파일을 생성하고, 여러 FASL을 하나로 묶어 각 시스템을 하나의 FASL로 제공할 수 있습니다.
118+
monolithic-compile-bundle-op대상 시스템과 모든 종속성에 대해 하나의 FASL 파일을 생성하여 전체 애플리케이션을 하나의 FASL로 제공할 수 있습니다
119+
120+
(defsystem :mysystem :class :precompiled-system
121+
:fasl (some expression that will evaluate to a pathname))
122+
123+
;; asdf:operate == asdf:oos ( operate-on-system )
124+
125+
(asdf/output-translations:output-translations)
126+
asdf/output-translations:*output-translations*
127+
https://github.com/fare/asdf/blob/master/output-translations.lisp
128+
129+
https://www.sbcl.org/manual/asdf.html#Configuring-ASDF-to-find-your-systems
130+
131+
## asdf/defsystem
132+
133+
- <https://asdf.common-lisp.dev/asdf.html>
134+
- <https://www.sbcl.org/manual/asdf.html>
135+
- <https://qiita.com/MYAO/items/874aafcc531862c5f7c7>
136+
- <https://github.com/fare/asdf/blob/master/doc/best_practices.md>
137+
138+
139+
## uiop
140+
141+
UIOP(`U`tilities for `I`mplementation and `O`S-`P`ortability)
142+
143+
- <https://asdf.common-lisp.dev/uiop.html>
144+
- <https://quickdocs.org/uiop>
145+
- <https://zenn.dev/hyotang666/articles/3f7abcec6f8270>
146+
147+
``` lisp
148+
;; example
149+
150+
(require 'asdf) ; => ("ASDF" "asdf" "UIOP" "uiop")
151+
152+
(uiop:command-line-arguments) ; 커맨드라인 인자
153+
154+
(uiop:getenv "USER")
155+
156+
(uiop:run-program "firefox") ; 동기
157+
(uiop:launch-program "firefox") ; 비동기
158+
159+
(uiop:run-program (list "git" "--help") :output t)
160+
(uiop:run-program "htop" :output :interactive :input :interactive)
161+
162+
;;; pipe: ls | sort
163+
(uiop:run-program "sort"
164+
:input
165+
(uiop:process-info-output
166+
(uiop:launch-program "ls"
167+
:output :stream))
168+
:output :string)
169+
(uiop:with-temporary-file (:stream s :pathname p :keep t)
170+
(format t "path is ~a~%" p)
171+
(format s "hello, temporary file!"))
172+
173+
(uiop:quit 0)
174+
```
175+
176+
## Ref
177+
178+
- <https://asdf.common-lisp.dev/asdf.html>
179+
- <https://asdf.common-lisp.dev/uiop.html>
180+
- <https://asdf.common-lisp.dev/uiop.html#UIOP_002fOS>
181+
- <https://asdf.common-lisp.dev/uiop.html#UIOP_002fFILESYSTEM>
182+
- <https://asdf.common-lisp.dev/uiop.html#UIOP_002fUTILITY>
183+
- <https://asdf.common-lisp.dev/uiop.html#UIOP_002fPACKAGE>
184+
- <https://asdf.common-lisp.dev/asdf.html#Defining-systems-with-defsystem>

src/advanced/debug.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
11
# 디버그
2+
3+
(declaim (optimize (debug 3) (speed 0) (safety 3)))
4+
5+
(declare (ignore arg))
6+
7+
## Ref
8+
9+
- <https://malisper.me/category/debugging-common-lisp/>
10+
- [Debugging Lisp: fix and resume a program from any point in the stack - how Common Lisp stands out.](https://www.youtube.com/watch?v=jBBS4FeY7XM)
11+
- <https://cl-community-spec.github.io/pages/invoke_002ddebugger.html>

src/advanced/error.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
11
# 에러
2+
3+
error
4+
warn
5+
'simple-error
6+
(signal (make-condition 'error) )
7+
(define-condition my-condition (simple-condition) // 사용자 에러 정의
8+
)
9+
10+
// sb-xc (ignore-errors (error "wtf"))
11+
(unwind-protect (error "wtf")
12+
)
13+
14+
(invoke-debugger
15+
(trivial-backtrace:print-backtrace
16+
https://github.com/hraban/trivial-backtrace
17+
Portable simple API to work with backtraces in Common Lisp
18+
19+
20+
21+
handle-case
22+
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node346.html
23+
https://lisp-docs.github.io/cl-language-reference/chap-9/j-b-condition-system-concepts
24+
25+
https://cl-community-spec.github.io/pages/handler_002dbind.html

src/advanced/ffi.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# FFI(Foreign Function Interface)
2+
3+
4+
ABI(`A`pplication `B`inary `I`nterface)
5+
6+
C ABI C언어의 ABI
7+
8+
FFI(`F`oreign `F`unction `I`nterface)
9+
2. FFI는 ABI 호환을 맞춰주는 "인터페이스" 역할
10+
11+
libclang: Clang의 내부 AST(Abstract Syntax Tree)을 외부에서 분석할 수 있게 해주는 C API 라이브러리
12+
13+
14+
- cffi
15+
- <https://github.com/cffi/cffi>
16+
- <https://github.com/rpav/c2ffi>
17+
- <https://cffi.common-lisp.dev/>
18+
- cl-autowrap
19+
- <https://github.com/rpav/cl-autowrap>

src/advanced/macro.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,76 @@
11
# 매크로
2+
3+
| | |
4+
| --- | ------------ |
5+
| ` | Backquote |
6+
| , | Comma |
7+
| ,@ | Comma-splice |
8+
| ', | Quote-comma |
9+
10+
11+
12+
quote
13+
defmacro
14+
15+
매크로 확장
16+
M-x slime-macroexpand-all (C-c M-m)
17+
18+
매크로를 수정하게 되면 매크로를 쓴 함수 역시 다시 평가해야 하는데
19+
M-x slime-who-macroexpands 로 찾고 C-c C-k로 컴파일
20+
21+
22+
&body
23+
(gensym)
24+
variable capture
25+
26+
27+
- compile function
28+
- read time - reader macros
29+
- macro expansion time - macros
30+
- compilation time
31+
- run time - function
32+
33+
34+
alexandria:with-gensyms
35+
https://alexandria.common-lisp.dev/
36+
https://gitlab.common-lisp.net/alexandria/alexandria
37+
38+
39+
================================================================================================================================================
40+
define-symbol-macro
41+
symbol-macrolet
42+
43+
sharpsign(#) - https://www.lispworks.com/documentation/HyperSpec/Body/02_dh.htm
44+
45+
#. read-time evaluation
46+
47+
(defun func1 ()
48+
:my-func1)
49+
50+
(defun #.(func1) ()
51+
:kkk)
52+
53+
;;> (:func1)
54+
;;=> :FUNC10
55+
;;> (:my-func1)
56+
;;=> :KKK
57+
58+
(asdf:defsystem "mysystem"
59+
:decription "short description"
60+
:long-description
61+
#.(uiop:read-file-string (subpathname *load-pathname* "README.md")))
62+
63+
64+
- sly-macrostep
65+
- <https://github.com/joaotavora/sly-macrostep>
66+
67+
68+
- <https://cl-community-spec.github.io/pages/gensym.html>
69+
- <https://cl-community-spec.github.io/pages/quote.html>
70+
- <https://lispkorea.github.io/successful-lisp-kr/ch03/lesson_03.html>
71+
- <https://lispkorea.github.io/successful-lisp-kr/ch03/lesson_08.html>
72+
73+
74+
75+
- `gensym`
76+
- `quote`

src/advanced/network.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# network

0 commit comments

Comments
 (0)