Lisp-Actors icon indicating copy to clipboard operation
Lisp-Actors copied to clipboard

SBCL feasibility

Open ddph3dg opened this issue 1 month ago • 6 comments

What is your opinion on using this in SBCL? I see that there is some file mentioning this but it's not clear to me if the system would work as well vs LispWorks.

ddph3dg avatar Oct 07 '25 05:10 ddph3dg

I'm trying to go through the install process for SBCL, but being newish to Lisp I'm running into problems. I am very new to the package system but I have managed to get all the required libraries (asdf:load-system "some file"). I had also got mpcompat loaded. However useful-macros has me stumped at an error in "def-extensions". I think there is some kind of alias #:um which I am guessing is Useful Macros. I change this to #:com.ral.useful-macros in the file and that gets me to "basic-useful". But there I get lost.

ddpphh33 avatar Oct 14 '25 07:10 ddpphh33

Ahh yes…

You are missing my PROJECT-PACKAGES package that I load up at the very start.

The Quicklisp system allows people to submit their packages using their own chosen package names. And invariably, people choose the simplest, most direct, package names for themselves. Myself included. And so we collide in many cases.

So to counter this issue, I name my own packages with long composite names like "com.ral.useful-macros.def-extensions” to avoid collisions. But I hate typing such long names. So I invented my own system for referring to my local packages using carefully chosen, but terse, package name abbreviations.

PROJECT-PACKAGES intercepts LOAD and IN-PACKAGE, to perform a recursive translation from my abbreviations to the actual package name.

Here is my .sbclrc ` ;; ——————————————————————

(setf (logical-pathname-translations "PROJECTS") #+:MSWINDOWS (("DYLIB;**;*.*" "z:/usr/local/lib/**/*.*") ("LIB;**;*.*" "z:/usr/local/lib/**/*.*") ("LISPLIB;**;*.*" "z:/usr/local/Lisp/Source/**/*.*") ("LISP;**;*.*" "y:/projects/Lispworks/**/*.*") ("**;*.*" "y:/projects/**/*.*")) #-:MSWINDOWS (("DYLIB;;." "/usr/local/lib//.") ("LIB;;." "/usr/local/lib//.") ("LISPLIB;;." "/usr/local/Lisp/Source//.") ("LISP;;." "~/projects/Lispworks//.") (";." "~/projects//.")) )

#-quicklisp (let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname)))) (when (probe-file quicklisp-init) (load quicklisp-init)))

(ql:quickload :cl-advice) (load "~/projects/Lispworks/startup/project-packages-sbcl") (load "~/projects/lispworks/startup/project-mappings")

(asdf:initialize-source-registry `(:SOURCE-REGISTRY (:EXCLUDE "dbm-git-repo") (:TREE #P"~/projects/Lispworks/") :IGNORE-INHERITED-CONFIGURATION))

(defun asdf (lib &rest args &key &allow-other-keys) "Shortcut for ASDF." (apply 'asdf:oos 'asdf:load-op lib args))

(ql:quickload :com.ral.actors.extra) ;; ——————————————————————————— `

And here is project-packages-sbcl.lisp: ` ;; ------------------------------------------------------------ ;; project-packages-sbcl.lisp -- Package mapping for SBCL ;; ;; DM/RAL 10/22 ;; -----------------------------------------------------------

(defpackage #:com.ral.project-packages (:use #:common-lisp) (:export #:defproject #:map-name #:show-mappings ))

(in-package #:com.ral.project-packages)

(defvar mappings (make-hash-table)) (defvar map-lock (sb-thread:make-mutex)) (defvar bypass-mapping nil)

(defun normalize (name) (cond ((stringp name) (intern (string-upcase name) :keyword)) ((symbolp name) (normalize (symbol-name name))) (t (error "What!? (~S)" name)) ))

(defun do-defproject (pairs) (sb-thread:with-recursive-lock (map-lock) (dolist (pair pairs) (destructuring-bind (from-name to-name) pair (let ((from-name (normalize from-name))) (setf (gethash from-name mappings) to-name) ))) ))

(defmacro defproject (&rest pairs) `(do-defproject ',pairs))

(defun map-name (name &optional froms) (cond ((or bypass-mapping (packagep name)) name) (t (let ((norm-name (normalize name)) to-name) (when (find norm-name froms :test #'string=) (error "Cyclic mappong ~A" norm-name)) (sb-thread:with-recursive-lock (map-lock) (if (and ;; (char= #= (char norm-name 0)) (setf to-name (gethash norm-name mappings))) (map-name to-name (cons norm-name froms)) name)))) ))

(defun package-mapper (next-fn name) (declare (optimize speed)) (funcall next-fn (map-name name)))

(defun in-quicklisp-p (filename) (find "quicklisp" (pathname-directory filename) :test #'string=))

(defun loader (next-fn filename &rest args) (let ((bypass-mapping (in-quicklisp-p filename))) (apply next-fn filename args)))

(sb-ext:with-unlocked-packages (:cl) (cl-advice:make-advisable 'cl:find-package :arguments '(name) :force-use-arguments t) (cl-advice:make-advisable 'cl:in-package :arguments '(name) :force-use-arguments t) (cl-advice:make-advisable 'cl:load :arguments '(name &rest args) :force-use-arguments t) (cl-advice:make-advisable 'cl:compile-file :arguments '(name &rest args) :force-use-arguments t) (cl-advice:add-advice :around 'cl:find-package #'package-mapper) (cl-advice:add-advice :around 'cl:in-package #'package-mapper) (cl-advice:add-advice :around 'cl:load #'loader) (cl-advice:add-advice :around 'cl:compile-file #'loader))

;; ------------------------------------------------------

(defun show-mappings () (let (lst) (sb-thread:with-recursive-lock (map-lock) (with-hash-table-iterator (gen mappings) (loop (multiple-value-bind (more? key value) (gen) (unless more? (return)) (push `(,key ,value) lst))))) (with-standard-io-syntax (pprint (sort lst #'string< :key #'car))) (values)))

;; ————————————————————————— `

And here is project-mappings.lisp ` ;; ———————————————————————— (com.ral.project-packages:defproject (#:project #:com.ral.project-packages) (#:um #:com.ral.useful-macros) (#:def* #:com.ral.useful-macros.def-extensions) (#:aop #:com.ral.useful-macros.dflet) (#:uuidgen #:com.ral.uuidgen) (#:cps #:com.ral.cps)

(#:plt #:plotter) (#:vm #:vmath) (#:vmath #:com.ral.vectorized-math) (#:vops #:vector-ops) (#:vector-ops #:com.ral.vector-ops) (#:mat #:com.ral.matrix-ops) (#:interpolation #:com.ral.interpolation) (#:fft #:com.ral.fft) (#:sfft #:com.ral.sfft) (#:dfft #:com.ral.dfft) (#:fft2d #:com.ral.fft2d) (#:roots #:com.ral.roots) (#:lmfit #:com.ral.lmfit) (#:linfit #:com.ral.linfit)

(#:mpc #:mpcompat) (#:mpcompat #:com.ral.mpcompat) (#:ca #:c-arrays) (#:c-arrays #:com.ral.c-arrays) (#:engfmt #:com.ral.useful-macros.engfmt) (#:uuid #:com.ral.uuid) (#:usec #:com.ral.usec)

(#:scatter-vec #:com.ral.scatter-vec) (#:mgdbuf #:com.ral.managed-buffers) (#:ubstream #:ubyte-streams) (#:ubyte-streams #:com.ral.ubyte-streams) (#:self-sync #:com.ral.self-sync) (#:loenc #:com.ral.lisp-object-encoder) (#:sets #:com.ral.rb-trees.sets) (#:maps #:com.ral.rb-trees.maps) (#:ref #:com.ral.ref) (#:priq #:com.ral.prio-queue) (#:ord #:com.ral.ord) (#:orderable #:com.ral.orderable)

(#:ac #:actors) (#:actors #:com.ral.actors) (#:vrepr #:vec-repr) (#:vec-repr #:com.ral.vec-repr) (#:vr #:vec-repr) (#:edec #:com.ral.crypto.edwards-ecc) (#:modmath #:com.ral.crypto.modular-arith) (#:hash #:com.ral.crypto.hash) (#:prng #:com.ral.crypto.prng) (#:kdf #:com.ral.crypto.kdf) (#:ciphers #:com.ral.crypto.ciphers) (#:primes #:com.ral.crypto.primes) (#:pbc #:com.ral.crypto.pbc-interface) (#:core-crypto #:com.ral.crypto.core-crypto) (#:kvdb #:com.ral.actors.kvdb) (#:fplht #:com.ral.useful-macros.fpl-hashtable) (#:restricted #:com.ral.useful-macros.restricted-eval) (#:debug-stream #:com.ral.useful-macros.debug-stream) (#:astro #:com.ral.astro) ) ;; ————————————————————————— `

On Oct 14, 2025, at 00:33, ddpphh33 @.***> wrote:

ddpphh33 left a comment (dbmcclain/Lisp-Actors#5) https://github.com/dbmcclain/Lisp-Actors/issues/5#issuecomment-3400484215 I'm trying to go through the install process for SBCL, but being newish to Lisp I'm running into problems. I am very new to the package system but I have managed to get all the required libraries (asdf:load-system "some file"). I had also got mpcompat loaded. However useful-macros has me stumped at an error in "def-extensions". I think there is some kind of alias #:um which I am guessing is Useful Macros. I change this to #:com.ral.useful-macros in the file and that gets me to "basic-useful". But there I get lost.

— Reply to this email directly, view it on GitHub https://github.com/dbmcclain/Lisp-Actors/issues/5#issuecomment-3400484215, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYDUAIJOY45SQF4PXILZHD3XSROJAVCNFSM6AAAAACIPF4AOKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMBQGQ4DIMRRGU. You are receiving this because you are subscribed to this thread.

dbmcclain avatar Oct 14 '25 09:10 dbmcclain

I have everything working in SBCL, except for the asynchronous socket connections. Lispworks has that already built in as a feature. I'd like to have the same thing in SBCL, but it seems a bit more daunting task to get to the basic facilities needed.

dbmcclain avatar Oct 14 '25 09:10 dbmcclain

OK that got me going. Now I know I can load it up I just need to spend a few months swapping out my old python & scheme code. BTW I had to comment out the multi-commit line in com.ral.actors.extra.asd as I hoped it wasn't important and I couldn't find the file "multi-commit" anywhere.

ddpphh33 avatar Oct 15 '25 08:10 ddpphh33

Yes, leaving out Multi-Commit is just fine.

Most of my coding is an experiment in what is possible. With multi-commit, I was looking for what it would take to keep multiple databases coherent across a change which needs to ripple across multiple databases. Mutli-commit was an experiment in this direction.

But be advised - I am a Physicist, not a database person. Apart from simple Key-value stores, I don't even know what I would do with a database.

dbmcclain avatar Oct 15 '25 13:10 dbmcclain

I'm an Experimental Physicist, so I can't even count properly.

ddpphh33 avatar Oct 16 '25 07:10 ddpphh33