openlang

obtaining symbol-name with original case

Can Common Lisp produce a symbol-name result that isn't converted to uppercase?

(symbol-name 'cCdD)
;; => "CCDD"

(ANOTHER_FUNCTION? 'cCdD)
;; => "cCdD"

I want the symbol's name in string form while preserving its letter case.

The conversation continues 2

Follow the reasoning
  1. Permalink

    The symbol really does have an uppercase name, since the reader has converted it already. To avoid this, change readtable-case or escape your symbol, either by surrounding it with pipes: '|cCdD| or by escaping each following character with backslash: '\cC\dD.

  2. Permalink

    This question has a fairly detailed explanation: Why does Common Lisp ignore letter case (https://stackoverflow.com/questions/7375537/why-is-common-lisp-case-insensitive)

    "A readtable object includes the readtable-case attribute, governing the reader's treatment of symbols during interning and evaluation. you may setf the readtable-case value to :upcase(default), or :downcase, :preserve, or :invert.

    The default value for readtable-case is :upcase, making the reader uppercase every symbol it encounters."

Other sides of the same question

  1. Escaping percent characters when calling String.Format?

    My strings.xml file holds a SQL query, and I'm trying to construct the finished string in code with String.Format. The SELECT…

    Replies 3Latest activity java
  2. Formatting strings with F#

    I'm building an F# library for the first time Using string.Format gives me a complaint saying that the function doesn't exist…

    Replies 2Latest activity fsharp
  3. Extracting one section of a tcl string

    With tcl I'm attempting to break apart Reports/Report#2.rpt and keep just Report#2.rpt ; I tried this approach, but it produc…

    Replies 2Latest activity tcl