Common Lisp マクロの種類
- macro form ; いわゆる「マクロ」
- (普通の)マクロ
- setf マクロ
- symbol macro
- reader macro
- (単一の) macro character
- dispatching macro character
- compiler macro
| (quicklisp:quickload '(#:anaphora #:iterate #:cl-ppcre)) | |
| (defpackage #:qldot | |
| (:use #:cl #:iterate #:anaphora #:ppcre)) | |
| (in-package #:qldot) | |
| (defparameter *font* "Courier New") | |
| (defmacro portname (sys &optional prj) |
Common Lisp マクロの種類
| lambda list の &aux の用途 | |
| - 単純な関数やlambdaを短く書きたいときに | |
| - 依存する dynamic 変数を lambda list に明示する | |
| - lambda list にbindした変数の一部を取り出すため、近所にまとめたいとき | |
| - もっとルーズに let のかわり |
| # MacOSXのHomebrewをアップデートした結果、OpenSSLが1.1系になって1.0系が使えなくなったけど、"Library not loaded: libcrypto.1.0.0.dylib issue in mac"とか出るのでOpenSSL 1.0系に戻したければ: | |
| brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb --force | |
| brew switch openssl 1.0.2t |
| (in-package :cl-user) | |
| ;;; これは、二回出てくる `#:hello' が別のシンボルなので、エラーになる。 | |
| ;; (flet ((#:hello () "Hello, World!")) | |
| ;; (#:hello)) | |
| ;; ; => Evaluation aborted on #<undefined-function @ #x105a7af3f2>. | |
| ;;; 一回目の `#:hello' を #n= と #n# で参照すればよい。 | |
| (flet ((#1=#:hello () "Hello, World!")) | |
| (#1#)) |
| (setf (logical-pathname-translations "asdf-cache") | |
| `(("**;*.*.*" | |
| ,(merge-pathnames | |
| (make-pathname :directory '(:relative :wild-inferiors)) | |
| asdf:*user-cache*)))) | |
| ; => (("**;*.*.*" #P"/Users/yokota/.cache/common-lisp/acl-10.1s-macosx-x64/**/")) | |
| (translate-logical-pathname "asdf-cache:bar;baz;mum.quux") | |
| ; => #P"/Users/yokota/.cache/common-lisp/acl-10.1s-macosx-x64/bar/baz/mum.quux" |
| (format t "~:{~A:~S~:^ ~}" | |
| '((:foo "100") (:bar "200") (:baz 9999))) ; Using a list of lists, not an alist. | |
| ; => FOO:"100" BAR:"200" BAZ:9999 |
| #| | |
| Some experiments to understand the example of CLHS eval-when explanations. | |
| ( http://clhs.lisp.se/Body/s_eval_w.htm#eval-when ) | |
| ;;; #4: This always does nothing. It simply returns NIL. | |
| (eval-when (:compile-toplevel) | |
| (eval-when (:compile-toplevel) | |
| (print 'foo4))) | |
| |# |