[Sbcl-help] Undefined function with IMPORT / SHADOWING-IMPORT

1 view
Skip to first unread message

Bergmann Manfred

unread,
Aug 5, 2023, 10:55:54 AM8/5/23
to SBCL help
Hello.

I’m getting style warnings for undefined functions when using IMPORT or SHADOWING-IMPORT.

The package where this occurs is split in two files. An „interface“ and an „implementation“ part.
The „interface“ file is compiled first and it defines the package and uses IMPORT-FROM for some functions.
The „implementation“ part imports more functions via IMPORT / SHADOWING-IMPORT (after IN-PACKAGE).
When compiling, or loading via ASDF I’m getting the ‚undefined function‘ style warnings where the functions are used in the „implementation“ file.
But why? Looking at the package symbols (do-symbols) the functions are there.

I could of course also import those function via IMPORT-FROM, in which case I don’t get warnings.
But the functions are not yet used there, so I only want to import those in the file that extends the package.


Cheers,
Manfred

_______________________________________________
Sbcl-help mailing list
Sbcl...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help

Bergmann Manfred

unread,
Aug 6, 2023, 5:07:15 AM8/6/23
to SBCL help
Here is a simple example:

;bar.lisp
;---------

(defpackage :bar
(:use :cl)
(:export #:bar1
#:bar2))

(in-package :bar)

(defun bar1 ()
(format t "bar1~%"))

(defun bar2 ()
(format t "bar2~%"))


;foo1.lisp
;----------

(defpackage :foo
(:use :cl)
(:import-from #:bar
#:bar1))

(in-package :foo)


;foo2.lisp
;-----------

(in-package :foo)

(shadowing-import '(bar:bar2))

(bar1)
(bar2) ;; style-warning

So I’m not sure why the style warning for (bar2).

Anyone knows?

Cheers,
Manfred

Stas Boukarev

unread,
Aug 6, 2023, 12:49:32 PM8/6/23
to Bergmann Manfred, SBCL help
Wrap SHADOWING-IMPORT in an eval-when?

Bergmann Manfred

unread,
Aug 6, 2023, 1:06:13 PM8/6/23
to SBCL help
Alright, thanks. Seems to work.
I was writing here because I thought it’s something SBCL specific, but LispWorks raises the same style warnings.
Reply all
Reply to author
Forward
0 new messages