From ... From: Erik Naggum Subject: Re: Parsing strings into LISP syntax Date: 1999/11/06 Message-ID: <3150919272860240@naggum.no>#1/1 X-Deja-AN: 545349852 References: <80027o$v1$1@newsmaster.cc.columbia.edu> <801pjl$bnq$1@newsmaster.cc.columbia.edu> <3150903015555973@naggum.no> <802a6i$p4v$1@newsmaster.cc.columbia.edu> mail-copies-to: never X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 941930473 17329 195.0.192.66 (6 Nov 1999 23:21:13 GMT) Organization: Naggum Software; +47 8800 8879 or +1 510 435 8604; fax: +47 2210 9077; http://www.naggum.no NNTP-Posting-Date: 6 Nov 1999 23:21:13 GMT Newsgroups: comp.lang.lisp * "Pascal Saremsky" | I get the feeling I'm missing the essence of lisp here! well, just that INTERN is called by the Lisp reader when it sees a string of characters that doesn't match anything else. so when you write (defun times3 (x) (* x 3)) the Lisp reader has already interned the symbol for you, and (find-symbol "TIMES3") will return the symbol. at this point, we're getting too close for comfort to the Lisp reader's character case conversion algorithm, and you are well advised not to try to out-do it. for legacy reasons (a.k.a. "hysterical raisins"), the Lisp reader upcases; it could have downcased, it could have retained case; it upcases, but you don't have to do that. when you read that symbol as a string of characters, just call FIND-SYMBOL (or INTERN) on it directly, and the right symbol is returned. however, to get a symbol in Lisp with the same name, you must cause the Lisp reader to see the exact name, too. this essentially means that you have to cause INTERN not to do case conversion. using a very powerful Lisp reader mechanism, the read-time evaluator, you could do (defun #.(intern "times3") (x) (* x 3)) but we have special syntax for this common phenomenon: (defun |times3| (x) (* x 3)) you can actually cause the Lisp reader not to do case conversion, and this may be preferable in your own code. see the function READTABLE-CASE for the whole story. however, if you set up a case sensitive readtable for your Lisp code, remember that Common Lisp upcases, and you need to type in uppercase, too: (DEFUN times3 (x) (* x 3)) the aesthetics of this approach is, however, generally disputed. #:Erik -- Attention Microsoft Shoppers! MS Monopoly Money 6.0 are now worthless.