how to write in a block(?) a very long "block" of statements



On 5/30/07, Viktor Nagy <viktor.nagy at gmail.com> wrote:
>
> My problem is that lambda is not evaluated in any of these expressions,
> even if it is evaluated in the original formulation.
>

Dear Viktor,

Your example is rather complicated, but if I'm not mistaken, it comes down
to the following:

         expr: alpha$
         s() := expr$
         ev( s(), alpha=3 );

You are expecting the last line to evaluate to 3, but it evalutes to alpha.
This is a misunderstanding of the operation of ev.  ev(EX,alpha=3) does not
substitute 3 for alpha in the result of evaluating EX; it merely creates an
environment in which alpha=3 and evaluates EX in that environment.  It does
not *reevaluate* existing expressions.

Perhaps this confusion comes from the rather complicated semantics of ev,
since after all ev(expr, alpha=3) evaluates to 3, and you might reasonably
expect that wrapping expr in a function wouldn't change anything.  But it
does.  This is one of the many reasons I do not recommend using ev in
programming.  (In fact, I have documented my many reasons to avoid ev in
general in previous emails.)

However, you can have ev do what (I think) you expect by adding "infeval" to
all your ev's.
      ev(s(), alpha=3, infeval) => 3

That said, I would strongly recommend a solution using "subst" instead of
ev.  Ev is really not designed for programming, but for interactive use.

              -s