Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3988684
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:16:54+00:00 2026-05-20T06:16:54+00:00

First, I am very new to lisp, so it is possible that I’m just

  • 0

First, I am very new to lisp, so it is possible that I’m just missing something very obvious. That said, I have Practical Common Lisp open next to me and the CL Hyper Spec open in the next tab, and have been unable to solve this issue:

I am trying to read a tree from a file, and assign values to slots in a class using this code:

(defun load-char (file)
  (with-open-file (in file)
    (with-standard-io-syntax
      (let ((chr-in (read in))
            (chr (make-instance 'pc)))
        (mapcar #'(lambda (x) (setf (slot-value chr (car x)) (cdr x))) chr-in)
        chr))))

When I originally hacked this together and ran it under the cl-user package everything worked perfectly — I was quite proud of myself, actually. The problem started when I packaged this along with my class definition and a few helper functions in a new package. I loaded the package using asdf, then used (in-package :package-name) to change my REPL’s active package.

Now when I run (load-char "/path/to/file") I get an error that says the COMMON-LISP-USER::ID (ID is the first slot in my pc class) does not exist, so I wrote this to see what I was actually getting when I read the file in:

(defun load-char-test (file)  
  (with-open-file (in file)  
    (with-standard-io-syntax  
      (let ((chr-in (read in))  
            (chr (make-hash-table)))  
        (mapcar #'(lambda (x) (setf (gethash (car x) chr) (cdr x))) chr-in)  
        (maphash #'(lambda (k v) (format t "~a: ~a~%" k v)) chr)
        chr))))

Then in the REPL I do (defparameter hsh (load-char-test "/path/to/file")) and everything goes without errors, and my format call returns exactly what I expect (SLOT: VALUE). But when I do a (gethash 'id hsh) it returns NIL NIL. But, when I do (gethash 'common-lisp-user::id hsh) it returns the expected value.

So, I’m reading in everything just fine, but everything in my list is being interned under the COMMON-LISP-USER package instead of the one I defined, and I cannot figure out why. Help is greatly appreciated.

P.S. Sorry if this post is needlessly long, I just wanted to show that I had actually tried to figure this out myself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:16:55+00:00Added an answer on May 20, 2026 at 6:16 am

    Symbols created by READ are interned in the package that is the current value of *PACKAGE* at runtime, not the value *PACKAGE* had when the code that calls READ was defined. One option, then, is to wrap your reading forms in a form that binds *PACKAGE*, e.g.

    (let ((*package* (find-package :package-name)))
      ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to programming and I must be missing something here. The first
I'm very new to Objective-C and have just made my first app from scratch.
First off I am very new to Objective C and iPhone programming. Now that
I'm very new to MVC, and just building my first site, using NerdDinner as
I have been slowing learning and building my first android app. I'm VERY new
I am very new to XSLT, and the first thing that i need to
I'm very new with iOS Development and I have just created one of my
I'm very new to Orchard CMS and I have started writing my first module.
Im very new to xcode and i have a question to my first app.
I am still very new and trying my first serious data binding. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.