Problems with EV



On 5/16/07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> Here's some more bizarreness in EV I ran across while working on something
> else (not EV).... Perhaps I should start a Wiki page on EV to document
> it....

Yes, that sounds like a great idea.

> Quotes and noeval are hard to understand.

> B  'x, x=9                   => 9     Hey, why ignore the quote?

Entering ev(expr, ...) actually causes expr to be evaluated twice.
So anything that you expect to be quoted has be quoted twice ...
I'm not saying this is a good idea.

(%i1) (aa : bb, bb : cc, cc : dd, dd : ee);
(%o1)                                 ee
(%i2) [ev(aa), ev(' aa), ev(' ' aa), ev(' ' ' aa), ev(' ' ' 'aa)];
(%o2)                      [cc, bb, aa, 'aa, '('aa)]

It appears to be that the effect of noeval in, say, ev(expr, x=foo) is
to substitute foo for x in expr and return the result without further
evaluation. I'm not sure what to expect from noeval but I wouldn't
have expected that ....

(%i3) [ev(aa), ev(' aa), ev(' ' aa), ev(' ' ' aa), ev(' ' ' 'aa)], noeval;
(%o3)        [ev(bb), ev(aa), ev('aa), ev('('aa)), ev('('('aa)))]
(%i4) [ev(aa), ev(' aa), ev(' ' aa), ev(' ' ' aa), ev(' ' ' 'aa)],
aa=42, noeval;
(%o4)        [ev(42), ev(42), ev('42), ev('('42)), ev('('('42)))]

noeval inhibits one of the two evaluations so the arguments
of ev get evaluated at least once. Interesting.

>  Is this behavior that any sane user will find intelligible, consistent, and
> sensible?

Well, what we really need is a function which can be explained
more briefly than by paraphrasing the source code.
If that's something you want to work on, have at it!

Robert