From ... From: Erik Naggum Subject: Re: Interned Symbols and GC Date: 2000/02/08 Message-ID: <3159028659830535@naggum.no>#1/1 X-Deja-AN: 583378915 References: <14709548.3158918965@pc34763.psy.cmu.edu> mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 950046168 5239 195.0.192.66 (8 Feb 2000 21:42:48 GMT) Organization: Naggum Software; +47 8800 8879 or +1 510 435 8604; fax: +47 2210 9077; http://www.naggum.no User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 Mime-Version: 1.0 NNTP-Posting-Date: 8 Feb 2000 21:42:48 GMT Newsgroups: comp.lang.lisp * Christian Lebiere | For better or worse, our application generates lots of interned symbols. well, if you don't use the Lisp reader to find symbols by name, there are always a number of available solutions better than using interned symbols. if, say, you only use symbols as unique keys, but whose name does not actually matter, a fresh cons cell like (nil . nil) may be used as long as you keep the key around someplace else. if the name matters, you can also use a string. | MCL seems to garbage-collect interned symbols after a while when they are | no longer referenced (which hasn't caused a problem so far), while | Allegro CL seems to keep them around forever (which causes it to bog down | and crash if given enough time). | | I have a couple of questions: | | 0) Is the above description accurate? no. an interned symbol is ipso facto referenced -- by the very package in which it is interned! moreover, whether a symbol is "useless" or not is not determined by what references the symbol, but by what the symbol references -- quite the opposite of your concern. the whole point with an interned symbol is that it holds onto some values and that there might be a reference to those values in the future through the symbol by its name read from an outside source, so _clearly_ we can't chuck interned symbols -- it would defeat the fundamental purpose of symbols. (aggressive short-sightedness is required to label this fact "unfortunate", as some evidently do.) | 1) What is the correct behavior, if there is one (CLTL2 has little to say)? since MCL is clearly in the wrong as you have described it, I'm inclined to think that something else is at work. btw, CLtL2 is no longer _the_ language reference. use the HyperSpec (or the standard). | 2) Is there a way to get rid of interned symbols that are no longer | needed that is safer and more efficient than to explicitely unintern them | individually? DELETE-PACKAGE gets rid of the last reference to interned symbols that have no references, for all symbols in that package. you could always copy the symbols you need to a new package, and do your own copying garbage collection that way. iterators over symbols are allowed to unintern the symbol it looks at. you may want to use DO-SYMBOLS over the symbols in a package to get rid of the ones you don't need. it sounds as if what you _really_ want is a weak hash table that you index with _some_ unique key, as outlined at the start of this message. #:Erik