From: Frode Vatvedt Fjeld
Subject: Re: changing a symbol name
Date: 
Message-ID: <2h8ya95fqn.fsf@vserver.cs.uit.no>
"Frode Vatvedt Fjeld" <······@cs.uit.no> a �crit dans le message de

>> If the symbol is interned, or probably even member of any other
>> kind of hash-table, changing its name will lead to massive
>> confusion.

"Christophe Turle" <······@nospam.com> writes:

> And why?

Because the intern function must be able to map a string and a package
to the exact same symbol. In practice, the package is (the equivalent
of) a hash-table where the key is the symbol-names and the values the
symbol objects.

> How many times did you redefine a function or variable just to
> change its name ? a setf/symbol-name should have been more coherent,
> no?

Most certainly not. To the extent functions have names (strictly
speaking, it's only the other way around: names have functions), these
names are _symbols_, not strings. If you want to change the name of a
function, you change to a new symbol, not a new symbol-name.

For example:

  (setf (symbol-function 'new-name) (symbol-function 'old-name))

is one way to "rename" a function named old-name to new-name.

> If someone has put the symbol name in a hashtable, it is bad
> design. The key should have been the symbol not its representation.

Many implementation will 

> I think the contrary. If internally all, has it should be, reference
> are made to the symbol, there's no problem, all is still ok.

Trust me, massive confusion awaits anyone taking this path.

-- 
Frode Vatvedt Fjeld
From: Frode Vatvedt Fjeld
Subject: Re: changing a symbol name
Date: 
Message-ID: <2h4qkx55ud.fsf@vserver.cs.uit.no>
"Christophe Turle" <······@nospam.com> writes:

> It works because you are not general enough and because you use
> implementation details.

No, it works because I understand the concept of a name in Common Lisp.

> Below is an example showing the advantage of using symbols as
> references.
>
> (defvar *tests* ())
>
> (defmacro def-test (name)
>   `(progn
>      (defun ,name () (print "i'm a test"))
>      (push ',name *tests*) ))
>
> (def-test test1)
>
> [30]> (test1)
> "i'm a test"
> "i'm a test"
>
> [31]> (setf (symbol-function 'test2) (symbol-function 'test1))
> #<CLOSURE TEST1 NIL (DECLARE (SYSTEM::IN-DEFUN TEST1))
>   (BLOCK TEST1 (PRINT "i'm a test"))>
>
> [33]> (test2)
> "i'm a test"
> "i'm a test"
>
> [34]> *tests*
> (TEST1)
>
> oops !
>
> Changing the symbol name would have work, whatever the implementation
> details.

Your macro def-test implements the semantics that the variable *test*
will hold a list of names of tests, not a list of tests
(i.e. functions). When you have a list of names, it does not make
sense to "change the name of a name". Write your like this:

  ... (push (symbol-function ',name) *tests*) ...

and you will have a list of tests. (I am disregarding the issue of
non-symbol function-names for now.) However I don't really know what
problem you are addressing either way.

What you are trying to do is to change the name of a name. That is
just non-sensical.

-- 
Frode Vatvedt Fjeld