jscl icon indicating copy to clipboard operation
jscl copied to clipboard

Standard symbol collisions

Open davazp opened this issue 12 years ago • 3 comments

It is useful to use another name for existing functions in the host Lisp implementation. So we will be able to use it and test it interactively without compiling JSCL once and again.

We could use ! to prefix such symbols and rename them in the end of the bootstrap.

davazp avatar Apr 26 '13 18:04 davazp

I'm taking care of this. The approach is that for every function named with ! prefix an alias without the prefix will be created. Therefore any function which would collision with host function should be prefixed: !read-from-string, !read, !compile-file, !parse-integer, !proclaim, etc.

abeaumont avatar Apr 27 '13 17:04 abeaumont

As a suggestion, it would perhaps be less noise if instead the package itself were renamed during cross-build?

eg:

(defpackage #+jscl common-lisp #-jscl jscl/common-lisp
    (:use) ; nothing!
    (:nicknames #+jscl #:jscl/common-lisp #:cl #:jscl/cl))
;; Use whichever CL is current; not JSCL/CL explicitly though
(defpackage jscl/int
    (:use :cl :jscl :jscl/ffi :jscl/mop :jscl/cltl2 :jscl/gray)) ; ambitious!
(defpackage my-jscl-app
   (:use #+jscl :cl #-jscl :jscl/cl))

(defun jscl/cl::format …)

The trick is to not use (in-package :jscl/cl) when reading the source code, so the dependent functions will use whichever CL package is correct for the runtime system, but you can always prefix the functions to call the JSCL-ish versions from within SBCL (or wherever). (in-package :jscl/int) perhaps.

brpocock avatar Dec 06 '16 20:12 brpocock

Yes. I have wanted to do this for a while.

SBCL uses a similar strategy as far as I know. Everything starts i the SB!xx packages, and just before finishing the packages are renamed to SB-xx instead.

It would make bootstrapping easier. I also want to avoid, if possible, the distintion between host and target files. I imagine a single file compat.lisp to provide in ANSI CL all JSCL provides in the core (emulate oget, etc), and using the renamed packages to load all the code in the host and in the target. It is too early to do that but this would help.

davazp avatar Dec 06 '16 22:12 davazp