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

Re: string > symbol?



>    (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