[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Structure sharing



KCL recently surprised me with the following behavior:

(setf foo 'filename) => FILENAME

(setf bar (namestring foo)) => "FILENAME"

(setf bar (nstring-downcase bar)) => "filename"

foo => {causes error}

It seems that in KCL. namestring of a symbol merely returns a
simple-string whose characters are SHARED with the print-name of the
symbol FILENAME!

As far as I can tell, this kind of sharing is perfectly legit, even
though it is very unintuitive.  Even parse-namestring returns a
pathname that shares characters with the string it was given!

I think it would be a good idea for CLtL to explicity state that
unless otherwise noted, a given function may return an object that
shares structure with another object.  And it would help to give a few
examples like parse-namestring and namestring to point out the
non-obvious consequences.

	-- Nick