axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] any?, member?, ...


From: William Sit
Subject: Re: [Axiom-developer] any?, member?, ...
Date: Wed, 23 Jun 2004 11:36:10 -0400


Martin Rubey wrote:
> 
> William Sit writes:
>  > That was my thoughts when I read your preliminary patch 3148:
>  >
>  > >      dvdsum(l, x) ==
>  > >        x = retract(y := third l)@SE => 0
>  > > -      k := retract(d := second l)@K
>  > > -      differentiate(h := third rest rest l,x) * eval(f := first l, k, h)
>  > > -        - differentiate(g := third rest l, x) * eval(f, k, g)
>  > > -             + opdsum [differentiate(f, x), d, y, g, h]
>  > > +      if member?(x, variables(h := third rest rest l)) or
>  > > +         member?(x, variables(g := third rest l)) then
>  > > +        dm := dummy
>  > > +        kernel(opdiff, [eval(opdsum(l), x::F, dm), dm, x::F])
>  > > +      else
>  > > +        opdsum [differentiate(first l, x), second l, y, g, h]
>  > >
>  >
>  > Note that g would not have been defined in some cases in the last line if
>  > the operator OR does not evaluate all its clauses first.
> 
> Hmm, if the first member? succeeds, g won't be defined but that's no problem,
> because it won't be used. If the first member? fails, the second member? will
> be evaluated and g will be defined. Only if both member? fail, the "else" part
> of the if statement will be evaluated and only in this case g is needed.

Ooops. You are correct.

But the point I was trying to make is that if side-effects in logical clauses
may be unevaluated, that would make assessing the correctness of the code more
difficult. (Your explanation above would have to be expanded if there were more
clauses).

BTW: should dm:=new()$SE be used instead?

William




reply via email to

[Prev in Thread] Current Thread [Next in Thread]