Hello,
is it possible to evaluate a string in LISP?
For example, there is a string "(pprint \"Hello World\")". Is it
possible to evaluate this string?
Regards
Michael
Michael H�nisch <················@ascad.de> writes:
> is it possible to evaluate a string in LISP?
>
> For example, there is a string "(pprint \"Hello World\")". Is it
> possible to evaluate this string?
>
Combine eval with read-from-string
--
Howard Ding
<······@hading.dnsalias.com>
On Wed, 15 Sep 2004 14:44:48 +0200, Michael H�nisch <················@ascad.de> wrote:
> is it possible to evaluate a string in LISP?
>
> For example, there is a string "(pprint \"Hello World\")". Is it
> possible to evaluate this string?
Try
(eval (read-from-string "(print \"Hi\")"))
but note that a) READ-FROM-STRING will read only one object from the
string and b) EVAL evaluates the form in the "null lexical
environment" - see the HyperSpec for details:
<http://www.lispworks.com/reference/HyperSpec/Front/index.htm>
Edi.
--
"Lisp doesn't look any deader than usual to me."
(David Thornley, reply to a question older than most languages)
Real email: (replace (subseq ·········@agharta.de" 5) "edi")