[pro] The Best Examples of "Code is Data"

Kazimir Majorinc kazimir at chem.pmf.hr
Thu Sep 23 19:53:49 UTC 2010


OK, but both of you paid more attention to the additional niceties or
advantages, unspecified in the problem, than to confirm or reject the
claim that eval is the best solution for problem under specified
criteria "simpler is better."

It looks to me as implicit claim "Yes, eval is the best solution of that
problem, but if the problem is developed further, other approaches (like
few mentioned) will (soon?) prevail."

Is it right?

Anyone else?


------------------------------
Kazimir Majorinc:

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


Scott McKay

>>
>> 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.
>
>> 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. :-)
>>

Daniel Weinreb:

>
> I'll add that if you can make the tiny subset have no side effects,
> there are lots of good properties of that.
>
> And if you can make it declarative, that has big advantages, although
> that might provide not enough power, depending on what you're
> planning to use this for.
>





More information about the pro mailing list