Mutation

Scott L. Burson gyro@zeta-soft.com
Fri, 16 May 1997 15:02:15 -0700 (PDT)


   From: Pierpaolo Bernardi <bernardp@CLI.DI.Unipi.IT>
   Date: Fri, 16 May 1997 18:42:25 +0200 (MET DST)


      From: "Scott L. Burson" <gyro@zeta-soft.com>
      ...

      I kinda thought `symbol-name' would have to copy the string as you suggest,
      but one day just a few weeks ago I typed the following at Allegro/Unix:

	(eq (symbol-name 'foo) (symbol-name 'foo))

      and got back T.  "Odd", sez I, "what happens if I modify the string?"  Well,
      to make a long story short, it eventually became clear that Allegro has some
      way of detecting modifications of strings that have been returned from
      `symbol-name', and what it does when it detects one is to make a new copy of
      the symbol's name.  Thus:

   You are misunderstanding what you see.

	> (setq *str* (symbol-name 'foo))
	"FOO"
	> (setf (char *str* 0) #\G)
	#\G

   Now you have messed up the symbol FOO

	> *str*
	"GOO"

	> (symbol-name 'foo)
	"FOO"

   INTERN does not find anymore the old foo, so another symbol named FOO
   is created.

*GASP*  You're quite right.

-- Scott