axiom-developer
[Top][All Lists]

## [Axiom-developer] [#183 #3161: any? and every? should exit when the resu

 From: kratt6 Subject: [Axiom-developer] [#183 #3161: any? and every? should exit when the result is clear ] Date: Thu, 23 Jun 2005 03:54:02 -0500

Changes
http://page.axiom-developer.org/zope/mathaction/1833161AnyAndEveryShouldExitWhenTheResultIsClear/diff
--

??changed:
-> >  > #3161:  any? and every? should exit when the result is clear [A]
-> >
-> > I don't have the time to look it up right now, whether the
-> > "mixed" behaviour TREE would vanish with this patch or not.
-> > In any case, this "bug" will never produce mathematically
-> > incorrect results. It will only waste cpu cycles.
->
-> Can we be sure that functions applied during evaluating 'any?'
-> and 'every?' are not being executed for their side-effects?
-> I worry that changing the semantics here could have unexpected
-> effects in other places in Axiom where 'any?' and 'every?' are
-> used.
->
-> > In fact, I included the comment regarding TREE only to document
-> > that if there would be code that depends on the "evaluate all"
-> > code, it wouldn't work with TREE anyway, so it would be broken
-> > already. Bottom line: no danger.
->
-> I am not convinced. I think this needs more analysis, i.e. look
-[1 more lines...]
any? and every? should exit when the result is clear.

As discussed in the thread starting with
http://lists.gnu.org/archive/html/axiom-developer/2004-06/msg00196.html
I believe that the following behaviour of 'any?' and 'every?' is bad, because
things are computed unnecessarily::

\begin{axiom}
any?(i+->(output(i);(i=1)::Boolean),[1,2,3])
\end{axiom}

The attached patch fixes this for HOAGG and CLAGG in 'aggcat.spad'. This makes
axioms behaviour more consistent also: in TBAGG, A1AGG, ARR2CAT, LZSTAGG the
functions are done as in the patch, in TREE a mixed behaviour is exhibited (and
should be fixed)

Martin

Bill wrote:

Can we be sure that functions applied during evaluating 'any?'
and 'every?' are not being executed for their side-effects?
I worry that changing the semantics here could have unexpected
effects in other places in Axiom where 'any?' and 'every?' are
used.

Martin replied:

In fact, I included the comment regarding TREE only to document
that if there would be code that depends on the "evaluate all"
code, it wouldn't work with TREE anyway, so it would be broken

Bill replied:

I am not convinced. I think this needs more analysis, i.e. look
at each case were 'any?' and 'every?' are actually used or else
we have to be prepared to do a lot of testing.

Martin replied:

--removed:
-
-Martin
-
-

--