[Openmcl-devel] make-symbol with uppercase/lowercase strings --

Pascal J. Bourguignon pjb at informatimago.com
Mon Jan 14 15:37:59 PST 2013


Dave Cooper <david.cooper at genworks.com> writes:

>     >
>     >  CL-USER> (make-symbol "heynow")
>     > #:|heynow|
>     > CL-USER> (make-symbol "HEYnOW")
>     > #:HEY\nOW
>     > CL-USER> (make-symbol "HEYnoW")
>     > #:|HEYnoW|
>    
>     Which part of above bothers you?  CCL is making symbols with name
>     you gave it.  To print them correctly some escaping (either
>     vertical bars or backslahes) is needed.  Apparently CCL chooses
>     shortest correct form, with ties in favour of bars -- in your
>     case uses backslash when only one character needs escaping
>     but bars otherwise.
>    
>
>
> None of it particularly bothers me. I was just wondering if there was
> some kind of pattern I was missing here.
>
> CL-USER> (make-symbol "AAbBABABaBABBAcBA")
> #:AA\bBABAB\aBABBA\cBA
>
> So it doesn't look like it's as simple as the shortest correct form. 
>
> I tried looking at CCL's source for make-symbol, but it lost me at
> symvector->symptr...
>
> Anyway it's enough to know that both printed representations are
> correct... so I'll go ahead and make my code deal with that. 


For more fun try:

(loop for *print-case* in '(:upcase :downcase :capitalize)
       do (loop for rtc in '(:upcase :downcase :preserve :invert)
             do (let ((*readtable* (copy-readtable nil)))
                  (setf (readtable-case *readtable*) rtc)
                  (format t "~:@(~16S ~16S~) ~{~16S~^ ~}~%"
                          *print-case* (readtable-case *readtable*)
                           '(HELLO |hello| |Hello| \hello)))))

(and that's not all you can do, *print-escape*, *print-circle* and
*package* have also an impact on the way symbols are printed).

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




More information about the Openmcl-devel mailing list