[Newbie] problem with conditional expression



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

> I really do understand the motivation for manipulable conditional
> expressions -- I've been advocating them for years (in fact, I think I
> was the first to advocate them on this list).  I just don't think they
> should be the same thing as programming conditionals, because they
> will lead to perverse results, e.g.
>
>       block([],
>                  if x>3 then return(3),
>                  5)
>
> always returns 5 (assuming x is undefined) with no indication anything
> was wrong.

This is a good example of the general principle I've been pushing:
attempting to prevent stupidity also prevents cleverness.
Cleverness is (among other things) being able to extrapolate from
known examples and predict the result of ones that haven't been
tried before. If Maxima handles partial evaluation of arithmetic and
other basic stuff without trouble, one would expect that Maxima is
happy with partial evaluation of conditionals as well. That's not a
speculation on my part: the message from Hugo Coolens is only
the most recent of various messages from people who didn't
expect Maxima to reject a partially evaluated conditional.

> In fact, in general, I would like to be able to perform *partial
> evaluation* on programs, but I don't want to do that by default.
> Partial evaluation would make
>
>       assume(zzz>3)
>
>       for i thru zzz do p:p+i
>
> return something like
>
>       (p:p+6,
>       for i from 4 thru zzz do p:p+1)
>
> Very nice, but not something I want from my default evaluator.

Neat. I'd like to see that too. That's exactly what I would expect to
see by extrapolating from the way Maxima handles arithmetic:
everything is an expression, and Maxima is happy with partial evaluation.

FWIW
Robert