Last active
October 22, 2015 13:41
-
-
Save eshamster/4b576de4c157aef958db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ----- package a ----- ; | |
(defpackage pack-a | |
(:use :cl)) | |
(in-package :pack-a) | |
(defun equal-name (l r) | |
(and (symbolp l) | |
(symbolp r) | |
(equal (symbol-name l) (symbol-name r)))) | |
; 文字列strをinternしてvalueを束縛する | |
(defmacro with-interned-str (str value &body body) | |
(let ((sym (intern (string-upcase str)))) | |
`(let ((,sym ,value)) | |
,@(sublis `((,sym . ,sym)) body | |
:test #'equal-name)))) | |
(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) | |
; => 300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment