[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string > symbol?
- To: gallagher@cs.umass.edu, info-mcl@digitool.com
- Subject: Re: string > symbol?
- From: allender@ils.nwu.edu (Laura Allender)
- Date: Wed, 22 Mar 1995 13:41:23 -0600
- Sender: owner-info-mcl@digitool.com
> (intern "(cons 1 2)") => |(cons 1 2)| ;; A symbol
>
> (read-from-string "(cons 1 2)" => (CONS 1 2) ;; A list
>
> (catch 'exit (read-from-string "#.(throw 'exit 'dumb)")) => DUMB
>
When the heck would I want |(cons 1 2)| as a symbol? Intern can be handy,
but in many systems you don't just want a symbol back, you want a symbol if
it's a symbol, a list if it's a list and a keyword if it's a keyword.
I can always write a cond statement (or multiple methods) to handle these
different cases. That's the nice thing about a litely typed language, you
don't
have to have lots of different code for different kinds of data -- the code
can handle it as long as your code is prepared for the alternatives.
Granted what you did in the third example is dumb. But then only a C enamored
efficiency junkie would think of doing something like that.
No offense meant. Well not much, I'm doing C++ for a living now anyway.
Laura