January 17, 2005
Shiftf Into Lisp

Ivan Shvedunov posted some cute code to SBCL-DEVEL that can convert C-style function names (Q3CreateMeshABC) to something more in the lisp style of naming (Q3-CREATE-MESH-ABC).

(defun make-field-name (alias)
  (with-output-to-string (s)
    (loop with last-caps = t
	  for ch across alias
	  when (and (not (shiftf last-caps (upper-case-p ch)))
	  do (princ #\- s)
	  do (princ (char-upcase ch) s))))

I changed Ivan's code slightly to insert dashes instead of spaces between tokens, and to upcase each character in order to create something most appropriate for passing to INTERN.

Posted by jjwiseman at January 17, 2005 03:03 PM
Post a comment

Email Address:


Unless you answer this question, your comment will be classified as spam and will not be posted.
(I'll give you a hint: the answer is “lisp”.)


Remember info?