Importing packages in SLIME

Discussion of Common Lisp
Post Reply
wvxvw
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

Importing packages in SLIME

Post by wvxvw » Fri Jun 01, 2012 4:24 am

There's something I can't understand about importing symbols or entire packages when in SLIME's REPL.
Suppose I want to use a socket, my inferior lisp program is SBCL, so I want to import several symbols from it, what I tried:

Code: Select all

(import 'sb-bsd-sockets:host-ent-address)
(import 'sb-bsd-sockets:get-host-by-name)
or

Code: Select all

(use-package :sb-bsd-sockets)
Both will argue about the symbols I'm trying to use are already in the common-lisp-user package, but they offer to resolve it, giving me two choices, either use those in cl-user, or those from sbcl package. I choose to use those in sbcl, which seems to resolve the error. Next, I try this:

Code: Select all

(defun nslookup (hostname) 
  (if hostname 
      (sb-bsd-sockets:host-ent-address (sb-bsd-sockets:get-host-by-name hostname)) 
      nil))
which works, but I don't like long names, so if I then try:

Code: Select all

(defun nslookup-1 (hostname) 
  (if hostname 
      (host-ent-address (get-host-by-name hostname)) 
      nil))
It doesn't work, saying that the functions I'm trying to call are undefined - even though I've just imported them! If I do in REPL:

Code: Select all

#'host-ent-address
#<STANDARD-GENERIC-FUNCTION HOST-ENT-ADDRESS (1)>
That is, it knows what it is, but it just will not use it...

This must be something special about SLIME because the same code executed as a shell script or directly from interactive shell with SBCL running in it would work.

So, my question is: what's happening? How to "fix" it, of course :)

edgar-rft
Posts: 226
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: Importing packages in SLIME

Post by edgar-rft » Fri Jun 01, 2012 7:15 am

Sorry, but can't reproduce your problem:

Code: Select all

CL-USER> (use-package :sb-bsd-sockets)
T

CL-USER> (defun nslookup-1 (hostname)
           (if hostname
               (host-ent-address (get-host-by-name hostname))
               nil))
NSLOOKUP-1

CL-USER> (nslookup-1 "localhost")
#(127 0 0 1)
Tested with:
  • GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1)
  • SBCL 1.0.57
  • SLIME 2012-05-12 (CVS version)
  • Linux debian-64 2.6.32-5-amd64 (Debian Squeeze)
But strange things can happen if you use e.g. an old SLIME version together with a new SBCL version or vice versa.

- edgar

wvxvw
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

Re: Importing packages in SLIME

Post by wvxvw » Fri Jun 01, 2012 10:34 am

I have the same Emacs 23.2.1, but older SLIME 2010-07-21 and SBCL is 1.0.40.0.debian. It's the same Debian Squeeze.
I actually solved it with help from Stackoverflow. When using shadow-import it just worked. idk why.

Post Reply