From: Pascal Bourguignon
Subject: Re: changing a symbol name
Date: 
Message-ID: <87hdoul2lr.fsf@thalassa.informatimago.com>
"Christophe Turle" <······@nospam.com> writes:

> I want to change a symbol name. But it is an error to do that, why ?
> 
> (setf (symbol-name 'myfunc) "myFunct")
> => attempt to to modify a read-only string: "MYFUNC"
> 
> From the semantic view point, i don't see why it is forbidden. I hope it's
> not for performance issue :(
> 
> Is there an easy way to hack this ? I really need this feature.

What you are missing IMO, is that the data structure used to store
symbols are merely implementation details. A lisp system would be as
valid if it did not had a "symbol table", and used only names. You
would still have a functions table and a values table and a plisp
table, they would merely map directly symbol name strings to function,
values or plist.

function table:
"COMMON-LISP:+"         --> <primitive:+>
"COMMON-LISP-USER:FACT" --> ("COMMON-LISP:LAMBDA" ("COMMON-LISP-USER:FACT")
                             ("COMMON-LISP:IF" 
                                ("COMMON-LISP:<" 0 "COMMON-LISP-USER:FACT")
                                ("COMMON-LISP-USER:FACT" 
                                  ("COMMON-LISP:*" 
                                      "COMMON-LISP-USER:FACT"
                                      ("COMMON-LISP-USER:FACT" 
                                         ("COMMON-LISP:1-" 
                                            "COMMON-LISP-USER:FACT"))))
                                1))
value table:
"COMMON-LISP-USER:FACT" --> ("COMMON-LISP-USER:\""
                             "COMMON-LISP-USER:HAL" "COMMON-LISP-USER:IS"
                             "COMMON-LISP-USER:AN" "COMMON-LISP-USER:AI"
                             "COMMON-LISP-USER:\"" "COMMON-LISP-USER:IS"
                             "COMMON-LISP-USER:A" "COMMON-LISP-USER:FACT")

Which shows you that to change the name, you'd have to scan the whole
system to find names inside existing functions and data, and to
determine whether you really want to change the name or not: do you
really want to change a dynamic variable or a function when you're
renaming the symbol used for a lexical binding?

There's a reason why the first LISPs did not have a string type!

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Voting Democrat or Republican is like choosing a cabin in the Titanic.