:export も大文字がよさそう
Package 名は大文字がよさそう、というのはPackage 名は大文字がよさそう - Shammerismでわかった。なので、:export も合わせてちょっとテスト。
? (defpackage "MY-PACKAGE" (:export "HELLO")) #<Package "MY-PACKAGE"> ? (in-package my-package) #<Package "MY-PACKAGE"> ? (defun hello () (format t "Hello!~%")) HELLO ?
自分で作成した Package の中で定義した関数をプレフィックスなしで別の Package から呼び出せるようにしたい。でもうまくいかない・・・
? (defpackage "MY-PACKAGE" (:export "HELLO")) #<Package "MY-PACKAGE"> ? (in-package my-package) #<Package "MY-PACKAGE"> ? (defun hello () (format t "Hello!~%")) HELLO ? (in-package common-lisp-user) #<Package "COMMON-LISP-USER"> ? (hello) > Error: Undefined function HELLO called with arguments () . > While executing: CCL::TOPLEVEL-EVAL, in process listener(1). > Type :GO to continue, :POP to abort, :R for a list of available restarts. > If continued: Retry applying HELLO to NIL. > Type :? for other options. 1 > q ? (HELLO) > Error: Undefined function HELLO called with arguments () . > While executing: CCL::TOPLEVEL-EVAL, in process listener(1). > Type :GO to continue, :POP to abort, :R for a list of available restarts. > If continued: Retry applying HELLO to NIL. > Type :? for other options. 1 > q ? (my-package::hello) Hello! NIL ?