[alexandria-devel] Question about FORMAT-SYMBOL
Hello, I often try to support Allegro's modern mode by doing things like (format-symbol t "~A-~A" :foo :bar). We just came across an issue on #quicklisp where a user had set his *PRINT-CASE* to :DOWNCASE and that caused FORMAT-SYMBOL to intern lower-case symbols, thus breaking the idiom I described. Should fix my code to use SYMBOLICATE instead or should FORMAT-SYMBOL use WITH-STANDARD-IO-SYNTAX? Any opinions? -- Luís Oliveira http://r42.eu/~luis
On 20 June 2011 22:28, Luís Oliveira <luismbo@gmail.com> wrote:
We just came across an issue on #quicklisp where a user had set his *PRINT-CASE* to :DOWNCASE and that caused FORMAT-SYMBOL to intern lower-case symbols, thus breaking the idiom I described.
Should fix my code to use SYMBOLICATE instead or should FORMAT-SYMBOL use WITH-STANDARD-IO-SYNTAX?
Any opinions?
Nikodemus Siivola <nikodemus@random-state.net> replied:
Using W-S-IO-S in FORMAT-SYMBOL sounds reasonable to me.
This has not been done, and is still needed. In particular, osicat-sys has (alexandria:format-symbol t "~A-~A" name '#:designator).
On Sat, Jul 28, 2012 at 5:03 PM, Orivej Desh <orivej@gmx.fr> wrote:
On 20 June 2011 22:28, Luís Oliveira <luismbo@gmail.com> wrote:
We just came across an issue on #quicklisp where a user had set his *PRINT-CASE* to :DOWNCASE and that caused FORMAT-SYMBOL to intern lower-case symbols, thus breaking the idiom I described.
Should fix my code to use SYMBOLICATE instead or should FORMAT-SYMBOL use WITH-STANDARD-IO-SYNTAX?
Any opinions?
Nikodemus Siivola <nikodemus@random-state.net> replied:
Using W-S-IO-S in FORMAT-SYMBOL sounds reasonable to me.
This has not been done, and is still needed. In particular, osicat-sys has (alexandria:format-symbol t "~A-~A" name '#:designator).
Speaking of symbolicate and format symbol, could we have something like the code below? Also can alexandria depend on asdf? If so, can we just reexport some ASDF utilities? Or else, can alexandria duplicate them? appendf, orf, strcat come to mind. Maybe also probe-file*, find-symbol*, while-collecting. Might already exist under different names: length=n-p, first-char, last-char, remove-keys, remove-keywords. Things that are incompatible: ends-with Also, no one replied to my previous nest proposals: (defmacro nest (&rest things) (reduce #'(lambda (outer inner) (append outer (list inner))) things :from-end t)) (defmacro tsen (&rest things) (reduce #'(lambda (inner outer) (append outer (list inner))) things :from-end nil)) (in-package :alexandria) (defun convert-to-string (x) "transform some stuff into a string" (typecase x (string x) (null "") (character (string x)) (symbol (symbol-name x)) (t (with-standard-io-syntax (princ-to-string x))))) (defun reduce/strcat (string-list &key (element-type 'character) new) "concatenate the contents" (cond ((null string-list) "") ((and (null (cdr string-list)) (not new)) (first string-list)) (t (loop :with length = (reduce #'+ string-list :key #'length) :with result = (make-string length :element-type element-type) :for index = 0 :then (+ index (length string)) :for string :in string-list :do (replace result string :start1 index) :finally (return result))))) (defun stringicate (&rest rest) "make a string by concatenating stuff" (reduce/strcat (mapcar #'convert-to-string rest))) (defun symbolicate-in (package &rest rest) (maybe-intern (apply 'stringicate rest) package)) (defun symbolicate (&rest rest) (apply 'symbolicate-in *package* rest)) (defun keywordicate (&rest rest) (apply 'symbolicate-in :keyword rest)) (defun gensymicate (&rest rest) (gensym (apply 'stringicate rest))) —♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org Any sufficiently advanced bug is indistinguishable from a feature. — Rich Kulawiec
On Mon, Jul 30, 2012 at 11:12 AM, Zach Beane <xach@xach.com> wrote:
Faré <fahree@gmail.com> writes:
Also can alexandria depend on asdf?
I very much hope not. I do not want to see any new practices that make it more difficult to replace ADSF when the time comes.
ASDF is not a utility library.
OK. So what about alexandria duplicate and export all the utilities in asdf? Alternatively, I could have a library called asdf-utils that imports and reexports those utilities, and somehow guarantees a stable interface, even if asdf is not used. As for replacing ASDF, I'm the first want to want that. Do you have any better plan than XCVB? (Or a plan that XCVB could follow to be more successful?) —♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org I'd rather write programs that write programs than write programs — Dick Sites
OK, so I created a trivial package asdf-utils to encapsulate those utilities. Is that OK with you to have software depend on that? http://common-lisp.net/gitweb?p=projects/asdf/asdf-utils.git —♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org The older I grow, the more I distrust the familiar doctrine that age brings wisdom. — H.L. Mencken
FiveAM is also affected with (setf accessor (format-symbol (symbol-package name) "~A-~A" '#:with name)) in def-special-environment in src/utils.lisp.
participants (5)
-
Faré
-
Luís Oliveira
-
Nikodemus Siivola
-
Orivej Desh
-
Zach Beane