Skip to content

Instantly share code, notes, and snippets.

@agam
Last active September 7, 2022 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agam/b45622fe8962c281c9540fcdfcc98cb2 to your computer and use it in GitHub Desktop.
Save agam/b45622fe8962c281c9540fcdfcc98cb2 to your computer and use it in GitHub Desktop.
Getting CIEL to work under Lispworks

Works fine in SBCL (though still needed some changes like avoiding fof and a new asdf version; some of that might be specific to the M1 Macbook I'm using)

Lispworks error:

CL-USER 1 > (ql:quickload "ciel")
To load "ciel":
  Load 1 ASDF system:
    ciel
; Loading "ciel"
.....On Lispworks, we cannot add method to DESCRIBE-OBJECT, so you cannot enjoy extended documentations for various namespaces...

**++++ Error in STATIC-DISPATCH.METHOD-FUNCTIONS::REDUCE13: 
  malformed
..

**++++ Error in STATIC-DISPATCH.METHOD-FUNCTIONS::MISMATCH27: 
  malformed
.....
; *** 2 errors detected, no fasl file produced.

Error: COMPILE-FILE-ERROR while compiling
#<ASDF/LISP-ACTION:CL-SOURCE-FILE "generic-cl.sequence" "src/sequence" "generic-sequences">
  1 (continue) Retry compiling
#<ASDF/LISP-ACTION:CL-SOURCE-FILE "generic-cl.sequence" "src/sequence" "generic-sequences">.
  2 Continue, treating compiling
#<ASDF/LISP-ACTION:CL-SOURCE-FILE "generic-cl.sequence" "src/sequence" "generic-sequences">
    as having been successful.
  3 Retry ASDF operation.
  4 Retry ASDF operation after resetting the configuration.
  5 Retry ASDF operation.
  6 Retry ASDF operation after resetting the configuration.
  7 (abort) Give up on "ciel"
  8 Register local projects and try again.
  9 Return to top loop level 0.

Traced this to :cl-generic

Specifically, this Github code

Disabled it!

Now, another failure:

**++++ Error between functions:
  Wrong character name: GREEK_SMALL_LETTER_LAMDA.

**++++ Error between functions:
  Wrong character name: GREEK_SMALL_LETTER_LAMDA.
; *** 2 errors detected, no fasl file produced.

Error: COMPILE-FILE-ERROR while compiling #<ASDF/LISP-ACTION:CL-SOURCE-FILE "fn" "fn">
  1 (continue) Retry compiling #<ASDF/LISP-ACTION:CL-SOURCE-FILE "fn" "fn">.
  2 Continue, treating compiling #<ASDF/LISP-ACTION:CL-SOURCE-FILE "fn" "fn"> as having been successful.
  3 Retry ASDF operation.

Fromthe quickdocs:

A couple of lambda shorthand macros. Their goal is to be used in cases where the word 'lambda and args are longer than the body of the lambda. It fixes this by adding implicit arguments.

(fn* (+ _ _))  -->  (lambda (_) (+ _ _))

(fn* (+ _ _1))  -->  (lambda (_ _1) (+ _ _1))

(fn* (subseq _@ 0 2))  -->  (lambda (&rest _@) (subseq _@ 0 2))
The λ reader macro is gives you the clojure like syntax.

λ(+ _ _)  -->  (lambda (_) (+ _ _))

λ(+ _ _1)  -->  (lambda (_ _1) (+ _ _1))

λ(subseq _@ 0 2)  -->  (lambda (&rest _@) (subseq _@ 0 2))
I REALLY dont like adding reader macros, but as λ is such a rarely used character I dont feel too bad about it.

Two options here:

  1. Avoid import entirely
  2. Use a local version that keeps the convenience function but not the reader macro

Looking for the repo, I think this is it

These are the offending lines

(defun lambda-reader (stream char)
  (declare (ignore char))
  (let* ((body (read stream t nil t)))
    (fn*-internals body nil)))

#-abcl
(named-readtables:defreadtable fn-reader
    (:merge :standard)
  (:macro-char #\GREEK_SMALL_LETTER_LAMDA #'lambda-reader t))

#-abcl
(named-readtables:defreadtable :fn.reader
    (:merge :standard)
	(:macro-char #\GREEK_SMALL_LETTER_LAMDA #'lambda-reader t))

#+abcl
(named-readtables:defreadtable fn-reader
    (:merge :standard)
  (:macro-char #\λ #'lambda-reader t))

#+abcl
(named-readtables:defreadtable :fn.reader
    (:merge :standard)
  (:macro-char #\λ #'lambda-reader t))

I interpret this as "ABCL doesn't define this, but other Lisps do ... which may not be good enough!"

Check the behavior of this symbol w.r.t. SBCL and Lispworks

Added Lispworks conditional

9:49:24 PM Now fails on another issue

[package printv]..
.
Error: Defining function :PPMX visible from package KEYWORD { *handle-warn-on-redefinition* is :ERROR }
   1 (continue) Define it anyway.
   2 Try loading /Users/agambrahma/.cache/common-lisp/lw-8.0.0-macosx-arm64/Users/agambrahma/quicklisp/dists/quicklisp/software/printv-20211230-git/printv.64yfasl again.
   3 Give up loading /Users/agambrahma/.cache/common-lisp/lw-8.0.0-macosx-arm64/Users/agambrahma/quicklisp/dists/quicklisp/software/printv-20211230-git/printv.64yfasl.
   4 Try loading another file instead of /Users/agambrahma/.cache/common-lisp/lw-8.0.0-macosx-arm64/Users/agambrahma/quicklisp/dists/quicklisp/software/printv-20211230-git/printv.64yfasl.
   5 Recompile printv and try loading it again
   6 Retry loading FASL for #<ASDF/LISP-ACTION:CL-SOURCE-FILE "printv" "printv">.
   7 Continue, treating loading FASL for #<ASDF/LISP-ACTION:CL-SOURCE-FILE "printv" "printv"> as having

Hmm, this is the key part:

Error: Defining function :PPMX visible from package KEYWORD { *handle-warn-on-redefinition* is :ERROR }

Maybe ... try loading after re-starting Lispworks? Nope

CL-USER 3 > *packages-for-warn-on-redefinition*
(:IMPLEMENTATION)

This works:

CL-USER 4 > (let ((*handle-warn-on-redefinition* nil)) (ql:quickload :printv))
To load "printv":
  Load 1 ASDF system:
    printv
; Loading "printv"

Added feature conditional for this.

But, no effect !!

I think it's because ... the error happens on loading the "fasl"

BTW, if I simply wrap it, I get the error on compile-time too:

Error: COMPILE-FILE-ERROR while compiling #<ASDF/LISP-ACTION:CL-SOURCE-FILE "printv" "printv">

Okay, not worth fixing it. Do the following:

  1. Exclude it from CIEL
  2. (later) replace the use of the keyword with a plain symbol (i.e. do we really need :printv? why not just use printv from a package?!)

Finally, it works

Sanity check:

CL-USER 27 > (in-package :ciel-user)
#<The CIEL-USER package, 13/16 internal, 0/16 external>
Error while reading: #\Space is an illegal character after a colon.

CIEL-USER 28 > (dict :a 1 :b 2)
#<EQUAL Hash Table{2} 801008F473>

Fixing up printv

The non-keyword version works:

CL-USER 6 > (printv:printv 
             (defparameter *y* 5)
             (defparameter *x* 10)
             (setf *y* (* 2 *x*))
             *x*)
;;;   (DEFPARAMETER *Y* 5) => *Y*
;;;   (DEFPARAMETER *X* 10) => *X*
;;;   (SETF *Y* (* 2 *X*)) => 20
;;;   *X* => 10
10

Had to add this re-export block:

(cl-reexport:reexport-from :printv
    :include '(:printv))

Now, works!

Custom repos:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment