CLisp: "use-package" resolving conflicts non-interactively

common-lisp, package

Solution

Instead of working in the COMMON-LISP-USER package, make your own with DEFPACKAGE:

(defpackage #:my-awesome-program
  (:use #:cl #:parenscript))

(in-package #:my-awesome-program)

; your code here

COMMON-LISP-USER might include all sorts of implementation-specific symbols.

You can also use SHADOWING-IMPORT to get individual symbols, overriding what might already be currently visible in the package, e.g.

(shadowing-import 'ps:*)

Problem

I'm trying to use parenscript in GNU common lisp to compile a lisp file into a javascript one. I find that using the PS symbol macro "@" doesn't work if I try to use its prefix ("ps:@"). However, if I use the REPL and run (use-package :ps) before I try compiling the lisp file, everything works as expected (and I don't have to use the prefixes). The problem is that the PS package contains clashing symbols, e.g: ``` *** - (USE-PACKAGE (#<PACKAGE PARENSCRIPT>) #<PACKAGE COMMON-LISP-USER>): 2 name conflicts remain Which symbol with name "CHAIN" should be accessible in #<PACKAGE COMMON-LISP-USER>? The following restarts are available: PARENSCRIPT :R1 #<PACKAGE PARENSCRIPT> COMMON-LISP-USER :R2 #<PACKAGE COMMON-LISP-USER> ABORT :R3 Abort main loop ``` I can resolve this interactively by choosing :r1, but when I try to put this step in my script it just bails (since it's non-interactive, it doesn't give me a choice of what restart to use) I'd love to say (in my script) "just use the PS version of all clashing symbols", but I can't figure out how to do so. It would also be okay if I could say (as one might in python), "from PS import chain, @, (etc)" - specifying each symbol I want to import manually.

Original source