Replies: 1 comment
-
The fixI fixed the (defpackage :com.gigamonkeys.text-db
(:use :common-lisp)
(:export com.gigamonkeys.text-db::open-db
com.gigamonkeys.text-db::save
com.gigamonkeys.text-db::store)) I also needed to substitute CodeWith these changes I was able to run the full code of chapter 21: (eql ':foo :foo)
(symbol-name :foo)
(eql '#:foo '#:foo)
(gensym)
*package*
common-lisp:*package*
cl:*package*
(defvar *x* 10)
*x*
:a
keyword:a
(eql :a keyword:a)
(defpackage :com.gigamonkeys.email-db
(:use :common-lisp))
(defpackage "COM.GIGAMONKEYS.EMAIL-DB"
(:use "COMMON-LISP"))
(in-package :com.gigamonkeys.email-db)
(defun hello-world () (format t "hello from EMAIL-DB package~%"))
(hello-world)
(in-package :xcl-user)
(defun hello-world () (format t "hello from XCL-USER package~%"))
(hello-world)
(defpackage :com.gigamonkeys.text-db
(:use :common-lisp))
(defun com.gigamonkeys.text-db::open-db () t)
(defun com.gigamonkeys.text-db::save () t)
(defun com.gigamonkeys.text-db::store () t)
(defpackage :com.gigamonkeys.text-db
(:use :common-lisp)
(:export com.gigamonkeys.text-db::open-db
com.gigamonkeys.text-db::save
com.gigamonkeys.text-db::store))
(defpackage :com.gigamonkeys.email-db
(:use :common-lisp :com.gigamonkeys.text-db))
(defpackage :com.acme.email
(:use :common-lisp))
(defun com.acme.email::parse-email-address () t)
(defun com.acme.email::build-index () t)
(defpackage :com.acme.email
(:use :common-lisp)
(:export com.acme.email::parse-email-address com.acme.email::build-index))
(defpackage :com.gigamonkeys.email-db
(:use :common-lisp :com.gigamonkeys.text-db)
(:import :com.acme.email :parse-email-address))
(defpackage :com.acme.text
(:use :common-lisp))
(defpackage :com.gigamonkeys.email-db
(:use
:common-lisp
:com.gigamonkeys.text-db
:com.acme.text)
(:import :com.acme.email :parse-email-address)
(:shadow :build-index))
(defpackage :com.gigamonkeys.email-db
(:use
:common-lisp
:com.gigamonkeys.text-db
:com.acme.text)
(:import :com.acme.email :parse-email-address)
(:shadow :build-index)
(:shadowing-import :com.gigamonkeys.text-db :save))
(defpackage :foolib
(:use :common-lisp))
(defun foolib::foo () t)
(defpackage :foolib
(:use :common-lisp)
(:export foolib::foo))
(foo)
(use-package :foolib) Session transcriptBelow is the transcript of the test session. The code apparently works as expected, including the intentional errors 2/8> (eql ':foo :foo)
T
2/9>
2/9> (symbol-name :foo)
"FOO"
2/10>
2/10> (eql '#:foo '#:foo)
NIL
2/11>
2/11> (gensym)
#:G30
2/12>
2/12> *package*
#<Package XCL-USER>
2/13>
common-lisp:*package*
#<Package XCL-USER>
2/14>
cl:*package*
#<Package XCL-USER>
2/15>
(defvar *x* 10)
*X*
2/16>
2/16> *x*
10
2/17>
:a
:A
2/18>
keyword:a
:A
2/19>
(eql :a keyword:a)
T
2/20>
2/20> (defpackage :com.gigamonkeys.email-db
(:use :common-lisp))
"COM.GIGAMONKEYS.EMAIL-DB"
2/21>
2/21> (defpackage "COM.GIGAMONKEYS.EMAIL-DB"
(:use "COMMON-LISP"))
"COM.GIGAMONKEYS.EMAIL-DB"
2/22>
2/22> (in-package :com.gigamonkeys.email-db)
#<Package COM.GIGAMONKEYS.EMAIL-DB>
2/23>
2/23> (defun hello-world () (format t "hello from EMAIL-DB package~%"))
HELLO-WORLD
2/24>
2/24> (hello-world)
hello from EMAIL-DB package
NIL
2/25>
2/25> (in-package :xcl-user)
#<Package XCL-USER>
2/26>
2/26> (defun hello-world () (format t "hello from XCL-USER package~%"))
HELLO-WORLD
2/27>
2/27> (hello-world)
hello from XCL-USER package
NIL
2/28>
2/28> (defpackage :com.gigamonkeys.text-db
(:use :common-lisp))
"COM.GIGAMONKEYS.TEXT-DB"
2/29>
2/29> (defun com.gigamonkeys.text-db::open-db () t)
COM.GIGAMONKEYS.TEXT-DB::OPEN-DB
2/30>
2/30> (defun com.gigamonkeys.text-db::save () t)
COM.GIGAMONKEYS.TEXT-DB::SAVE
2/31>
2/31> (defun com.gigamonkeys.text-db::store () t)
COM.GIGAMONKEYS.TEXT-DB::STORE
2/32>
2/32> (defpackage :com.gigamonkeys.text-db
(:use :common-lisp)
(:export com.gigamonkeys.text-db::open-db
com.gigamonkeys.text-db::save
com.gigamonkeys.text-db::store))
"COM.GIGAMONKEYS.TEXT-DB"
2/33>
2/33> (defpackage :com.gigamonkeys.email-db
(:use :common-lisp :com.gigamonkeys.text-db))
"COM.GIGAMONKEYS.EMAIL-DB"
2/34>
2/34> (defpackage :com.acme.email
(:use :common-lisp))
"COM.ACME.EMAIL"
2/35>
2/35> (defun com.acme.email::parse-email-address () t)
COM.ACME.EMAIL::PARSE-EMAIL-ADDRESS
2/36>
2/36> (defun com.acme.email::build-index () t)
COM.ACME.EMAIL::BUILD-INDEX
2/37>
2/37> (defpackage :com.acme.email
(:use :common-lisp)
(:export com.acme.email::parse-email-address com.acme.email::build-index))
"COM.ACME.EMAIL"
2/38>
2/38> (defpackage :com.gigamonkeys.email-db
(:use :common-lisp :com.gigamonkeys.text-db)
(:import :com.acme.email :parse-email-address))
"COM.GIGAMONKEYS.EMAIL-DB"
2/39>
2/39> (defpackage :com.acme.text
(:use :common-lisp))
"COM.ACME.TEXT"
2/40>
2/40> (defpackage :com.gigamonkeys.email-db
(:use
:common-lisp
:com.gigamonkeys.text-db
:com.acme.text)
(:import :com.acme.email :parse-email-address)
(:shadow :build-index))
"COM.GIGAMONKEYS.EMAIL-DB"
2/41>
2/41> (defpackage :com.gigamonkeys.email-db
(:use
:common-lisp
:com.gigamonkeys.text-db
:com.acme.text)
(:import :com.acme.email :parse-email-address)
(:shadow :build-index)
(:shadowing-import :com.gigamonkeys.text-db :save))
"COM.GIGAMONKEYS.EMAIL-DB"
2/42>
2/42> (defpackage :foolib
(:use :common-lisp))
"FOOLIB"
2/43>
2/43> (defun foolib::foo () t)
FOOLIB::FOO
2/44>
2/44> (defpackage :foolib
(:use :common-lisp)
(:export foolib::foo))
"FOOLIB"
2/45>
2/45> (foo)
Undefined car of form
FOO
2/46>
2/46> (use-package :foolib)
Package XCL-USER using FOOLIB results in name conflicts for symbols:
FOO
NIL
2/47> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Chapter 21. Programming in the Large: Packages and Symbols
This is the continuation of the work on issue #609. To evaluate the compatibility of Medley Common Lisp with ANSI Common Lisp I'm testing on Medley the code of Peter Seibel's book Practical Common Lisp.
Issues
To prepare for chapter 21 I started adding the usual missing definitions and calls, particularly this package whose symbols are accessed later in the code:
But evaluating it yields the error
Not an existing package, string or symbol
. So I rewrote it in two steps, first to define the package and then to define and export the symbols:This leads to the same error
Not an existing package, string or symbol
though.Code
Here is the code of the initial part of the chapter:
Session transcript
And this is the transcript of the test session with the errors:
Beta Was this translation helpful? Give feedback.
All reactions