<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
Scott McKay wrote:
<blockquote
cite="mid:994CD365-764B-4F0C-93B2-F4DD0783B889@itasoftware.com"
type="cite">
<pre wrap="">On Sep 14, 2010, at 1:07 PM, Kazimir Majorinc wrote:
</pre>
<blockquote type="cite">
<pre wrap="">On 8.9.2010 0:08, Daniel Weinreb wrote:
</pre>
<blockquote type="cite">
<pre wrap="">There is an old saying: if you are using "eval", you are
doing it wrong. So far I have yet to find any significant
exceptions to this rule.
</pre>
</blockquote>
<pre wrap="">Look at this:
The program generates propositional formulas S1, S2, ... using
some experimental algorithm. S1, ..., Sn are needed for generation of
Sn+1, as typical in deductive systems. The formulas contain logical
constants and already defined operators. The hypothesis is:
all generated propositional expressions are true.
The problem: write the function that tests that hypothesis for
any generated formula. Optimization is not needed. Simpler is better.
I'd use eval instead of defining any new function, as the simplest and
the most natural solution. What would others do? If you'd use eval as
well, do you think it is important or rare, maybe even 'artificial'
example.
</pre>
</blockquote>
<pre wrap=""><!---->
This is a place you could use 'eval', but...
- It depends on what the propositions contain.
If it's a tiny subset of Lisp (like 'and', 'or', 'not'),
a custom evaluator might be nicer.
- A custom evaluator might be faster, too, especially if you're
doing this in the context of some sort of SAT-solver where you've
got lots of propositions, and you might want caching, etc.
</pre>
</blockquote>
<br>
Yes, I was just about to hit reply and say all these things,<br>
but Scott got there first.<br>
<br>
I'll add that if you can make the tiny subset have no<br>
side effects, there are lots of good properties of<br>
that.<br>
<br>
And if you can make it declarative, that has big<br>
advantages, although that might provide not<br>
enough power, depending on what you're planning<br>
to use this for.<br>
<br>
-- Dan<br>
<br>
<blockquote
cite="mid:994CD365-764B-4F0C-93B2-F4DD0783B889@itasoftware.com"
type="cite">
<pre wrap="">
In the many years I've been using Lisp, I've used eval so few times,
and one of the times was in a debugger where I wanted to evaluate
Lisp forms. :-)
_______________________________________________
pro mailing list
<a class="moz-txt-link-abbreviated" href="mailto:pro@common-lisp.net">pro@common-lisp.net</a>
<a class="moz-txt-link-freetext" href="http://common-lisp.net/cgi-bin/mailman/listinfo/pro">http://common-lisp.net/cgi-bin/mailman/listinfo/pro</a>
</pre>
</blockquote>
</body>
</html>