Elisp久负"难学"的名声,
分析一下, 可能未必难在语言本身, 而是难在决策上, 在’分秒必争’的环境里去学习一种"无用之学". (颇为耐人寻味, lisp原以"实用主义"起家
且不论lisp这门古老FP语言怎样, elisp更像是shell script一般脚本语言, 堆砌命令, 区别是比bash还碎片.
本帖试图在两分钟内梳理框架结构, 节省几个小时的时间投入, 探讨crash elisp(秒一门语言)的大致思路:
承接 两分钟掌握50大章的Emacs Manual文档 - Emacs-general - Emacs China,
Elisp结构图分为 3. applications 2.text process methods 1.objects and concepts三个部分.
三.applications, 系统接口
- process and IPC (38章)
;;manipulate process
make(start)-process, call-process, call-proces-region
async-shell-command, shell-command,
delete-process
list-processes, get-process, list-system-processes
;;IPC
process-send-string, signal-process (input
process-buffer, process-filter, accept-process-output (output
- thread(37章)
;;manipulate thread
make-thread, thread-join, thread-yield
;;lock
with-mutex, mutex-lock, mutex-unlock
;;events
make-condition-variable
- I/O and File system (19, 20, 16, 25, 27
read, message, print
with-temp-buffer, insert
- System service (40)
(format-time-string "%a %b-%d %H:%M %p" (current-time))
一.Concepts and Objects
Cursor(point, mark), file, buffer, window, frame, mode, display
save-excursion,
add-hook
二.语言构件 (略
#+BEGIN_SRC elisp
(defun fib-iter (a b count)
(if (= count 0)
a
(fib-iter b (+ a b) (- count 1))
)
)
(defun fib(n)
(fib-iter 0 1 n))
(fib 3)
#+END_SRC
#+RESULTS:
: 2
#+BEGIN_SRC elisp
(defun factorial (n)
(fact-iter 1 1 n))
(defun fact-iter (product counter max-count)
(if (> counter max-count)
product
(fact-iter (* counter product)
(+ counter 1)
max-count)
)
)
(factorial 3)
#+END_SRC
#+RESULTS:
: 6
参考资料: