views:

51

answers:

1

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.

+4  A: 

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:*)
Xach
I've put that at the top of my file called "compiler.lisp", subbing "my-awesome-program" for "compiler":[1]> (load "compiler.lisp")>> RENAME-PACKAGE("SYSTEM"): #<PACKAGE SYSTEM> is lockedif I continue, ignoring this error, I get: USE-PACKAGE: There is no package with name "COMPILER".Is (load "compiler.lisp") the wrong function? should I require it or something else?
gfxmonk
The shadowing-import thing worked, thanks! I'm not sure what I've done to make the package stuff not work, I'll have to figure that out sometime later...
gfxmonk
I'd have to see your file. The error message doesn't make sense just from your description of it.
Xach
I take it you're using clisp as your implementation? It comes with a package called COMPILER already defined (it's a nickname for the package SYSTEM).
vsedach