Source of Nothingness - lisp

* Menu

[[About:self:AboutPage.txt]] | [[Profile:file/southly/]] | [[まとめ:self:1163859357.txt]] | [[オリジナル:http://ninjinix.x0.com/rn/]] | [[xyzzy:lisp/]] | [[あんてな:listall]] | [[■:sakura.ne.jp/southly/lisp/ni/view.lisp]] | [[buzz:http://www.google.com/profiles/southly#buzz]]

* lisp : スコープ

[[Scheme、Common Lisp、Emacs Lispの比較:http://www.ice.nuie.nagoya-u.ac.jp/~h003149b/lang/comparison.html]]
Common Lisp自体は静的スコープだけど、 大域変数は暗黙的にスペシャル変数となるので Emacs Lispと同様上のような結果になる。
ダウト!
もしかしてCLtL1のときはそういう仕様だったのかもと確認してみたけれど、変更された形跡もない。
トップレベルで定義されようとレキシカルスコープに変わりはない。

* Scrapbook : History of LISP ― Software Preservation Group

 http://community.computerhistory.org/scc/projects/LISP/

* 2007-04-30

* Scrapbook : Implementing LISP in LISP (1/3) ( 7-Feb-1996)

 lisp-1.html

* lisp : 値渡し?参照渡し?

関数一般についてはこの辺りが参考になります。
Schemeの話ですけど基本的に一緒。

* xyzzy lisp : シャッフル

(defun nswap (l x y)
  (rotatef (car (nthcdr x l)) (car (nthcdr y l)))
  l)

(defun nshuffle (l)
  (do ((i (length l) (1- i)))
      ((>= 1 i))
    (setq l (nswap l (1- i) (random i))))
  l)
元のデータを直接いじっていくほうが分かりやすくないッスか?
ってことでこんな。
nswapは関数にする必要は無いけど意味が分かりやすいように。

* xyzzy lisp : ミニバッファの入力にエスケープシーケンス

interactive指定子を作っちゃえば楽に置き換えられるんじゃね?
ってことで、こんな。
(in-package "editor")
(defun interactive-read-string-with-escape-sequence (prompt default history title)
  (list (decode-escape-sequence (read-string prompt :default default :history history) nil)))
(pushnew '(#\w . interactive-read-string-with-escape-sequence)
	 *interactive-specifier-alist* :test #'equal)
(defun interactive-read-regexp-with-escape-sequence (prompt default history title)
  (list (decode-escape-sequence (read-string prompt :default default :history history) t)))
(pushnew '(#\W . interactive-read-regexp-with-escape-sequence)
	 *interactive-specifier-alist* :test #'equal)

;; こんな感じで使う
;; 文字列
(defun search-forward-wes (pattern &optional noerror)
  (interactive "wSearch forward: "
    :default0 *last-search-string* :history0 'search)
  (search-command pattern nil nil (interactive-p) noerror))
;; 正規表現
(defun re-search-forward-wes (regexp &optional noerror)
  (interactive "WRe-search forward: "
    :default0 *last-search-regexp* :history0 'search)
  (search-command regexp nil t (interactive-p) noerror))
(export '(search-forward-wes re-search-forward-wes))
(in-package "user")

* 2007-03-27

; トップレベル
(setq x 1)
; 実験用関数
(defun f()
  x)
; lexicalな束縛
((lambda (x) (f)) 2)
=> 1
; (declare (special x)) によって、この環境ではxがスペシャル変数に昇格
((lambda (x) (declare (special x)) (f)) 2)
=> 2
; また新しい環境なので通常のlexicalな束縛
((lambda (x) (f)) 2)
=> 1

* Scrapbook : FreeTechBooks.com - Common Lisp

 viewforum.php?f=40
めも

* そこそこまとまっていて役に立つかもしれないもの