Skip to content

intern symbol not working properly if *print-case* is set to be :downcase #251

@li-yiyang

Description

@li-yiyang

Thank you for the project. I found that varjo package could not be loaded properly if I set *print-case* to be :downcase. The configuration of my .sbclrc is like below (reference: Common Lisp Tweaks):

;;; Stop Lisp from SCREAMING
(setf *print-case* :downcase)

So i've patched the source code like below:

modified   src/utils-v.lisp
@@ -1,5 +1,16 @@
 (in-package :varjo.utils)
 
+#+ryo
+(defun merge-as-string (&rest list)
+  "If you are same as me, setting `*print-case*' as `:downcase'
+to avoid screaming symbols from lisp. You may need this function. "
+  (with-output-to-string (stream)
+    (dolist (elem list)
+      (write-string (etypecase elem
+                      (string elem)
+                      (symbol (symbol-name elem)))
+                    stream))))
+
 (defun cons-end (thing list)
   (concatenate 'list list (list thing)))
 
@@ -89,7 +100,9 @@
   `(multiple-value-list ,value-form))
 
 (defun kwd (&rest args)
-  (intern (format nil "~{~a~}" args) 'keyword))
+  (intern #-ryo (format nil "~{~a~}" args)
+          #+ryo (apply #'merge-as-string args)
+          'keyword))
 
 (defun group (source n)
   "This takes a  flat list and emit a list of lists, each n long
@@ -125,7 +138,8 @@
    If the input is symbol/s then the output is a regular symbol
    If the input is string/s, then the output is
    a |symbol like this|"
-  (values (intern (format nil "~{~a~}" args))))
+  (values (intern #-ryo (format nil "~{~a~}" args)
+                  #+ryo (apply #'merge-as-string args))))
 
 (defun p-symb (package &rest args)
   "This takes a list of symbols (or strings) and outputs one
@@ -133,7 +147,9 @@
    If the input is symbol/s then the output is a regular symbol
    If the input is string/s, then the output is
    a |symbol like this|"
-  (values (intern (format nil "~{~a~}" args) package)))
+  (values (intern #-ryo (format nil "~{~a~}" args)
+                  #+ryo (apply #'merge-as-string args)
+                  package)))
 
 (defun assocr (item alist &key (key nil keyp) (test nil testp)
                             (test-not nil notp))
@@ -165,7 +181,10 @@
   (car (last list)))
 
 (defun lambda-list-split (template lam-list)
-  (labels ((kwd (x) (intern (format nil "~a" x) :keyword))
+  (labels ((kwd (x) (intern
+                     #-ryo (format nil "~a" x)
+                     #+ryo (merge-as-string x)
+                     :keyword))
            (symbol-name= (x y) (equal (symbol-name x) (symbol-name y)))
            (collector (lam-list &optional current-modifier accum)
              (let ((item (first lam-list)))

it passed on my machine (although I still stuck on SDL2, which should be another problem though). I don't know if it is the proper way for the original function, but I guess it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions