Skip to content

Instantly share code, notes, and snippets.

@eshamster
Last active October 22, 2015 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eshamster/8246522db00e61b38572 to your computer and use it in GitHub Desktop.
Save eshamster/8246522db00e61b38572 to your computer and use it in GitHub Desktop.
; ----- package a ----- ;
(defpackage pack-a
(:use :cl))
(in-package :pack-a)
; 文字列strをinternしてvalueを束縛する
(defmacro with-interned-str (str value &body body)
(let ((sym (intern (string-upcase str))))
`(let ((,sym ,value))
,@body)))
(with-interned-str "abc" 100
(print abc))
; => 100
; ----- package b ----- ;
(defpackage pack-b
(:use :cl))
(in-package :pack-b)
(defmacro some-macro (value)
`(pack-a::with-interned-str "def" ,value
(print def)))
(some-macro 200)
; => 200
; ----- package c ----- ;
(defpackage pack-c
(:use :cl))
(in-package :pack-c)
(pack-b::some-macro 300)
; Error => The variable PACK-B::DEF is unbound.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment