axiom-developer
[Top][All Lists]
Advanced

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

RE: [Axiom-developer] Axiom BNF


From: Bill Page
Subject: RE: [Axiom-developer] Axiom BNF
Date: Mon, 25 Oct 2004 22:28:03 -0400

Martin,

>From code you show below I would say that the problem is not
the placement of the 'else' block but rather the scope of the
'for' block. The second ("versus") part is very likely wrong
because of the reference to index variable g outside the for
loop. Also there is a minor formating error in the second part
because the 'else' block does not have the same indentation as
any preceeding 'if' block. Does the compiler actually compile
the second part without issuing an error?

I am completely sceptical that adding braces would make this
code any more clear or to help locate problems in the algorithm.

Code structure highlighting or folding of indented sections 
such as found in some Python integrated development environments,
e.g. PythonWin, or see

  http://www-106.ibm.com/developerworks/linux/library/l-pide/
  http://www-106.ibm.com/developerworks/linux/library/l-cpyide/

might help to make the structure of the program more readily
apparent. I wonder if anyone has ever done a good emacs mode for
SPAD "pile" highlighting and editing?

You write: "it is a real good thing that you can choose piles
or no piles". On the other hand in the previous message I rather
directly implied that this was a "bad thing". I think having
two different syntaxes for the same language is undesirable.
In my opinion in both programming and in mathematics adopting a
good (efficient, concise, standard, ...) notation is often more
than half the battle.

Regards,
Bill Page.

> -----Original Message-----
> From: Martin Rubey [mailto:address@hidden 
> Sent: Monday, October 25, 2004 4:37 PM
> To: Bill Page
> Cc: 'Martin Rubey'; address@hidden
> Subject: RE: [Axiom-developer] Axiom BNF
> 
> 
> Hi Bill!
> 
> here is the real life thing:
> 
>               if degree f.factor = 1 then
>                 Av := -coefficient(f.factor, 0)/leadingCoefficient
f.factor
>                 if Av ~= 0 then
>                   res5 := factor(univariate(eval(p3,'A::Symbol,Av)))$GF
>                   for g in factors res5 repeat
>                     if degree g.factor = 1 then
>                       a1v := -coefficient(g.factor, 0)
>                               /leadingCoefficient g.factor 
> 
>                       res := cons([rat2expr2(xx, ri.function, Av, a1v)
>                                    *(coerce(Av-(len+3)*a1v)
>                                      +coerce(a1v)*(xx::EXPRR))
>                                     **(xx::EXPRR), 
>                                    reduce(max, ri.unattainable, 0)
>                                      $List(Integer)::NNI], 
>                                   res)
>                     else
>                       a1v := kernel(opalg, [poly2expr(xx, g.factor),
xx::EXPRR])
>                       output(a1v::OutputForm)$OutputPackage
>               else
>                 a1v := kernel(opalg, [poly2expr(xx, f.factor), xx::EXPRR])
>                 output(a1v::OutputForm)$OutputPackage
> 
> versus
> 
>               if degree f.factor = 1 then
>                 Av := -coefficient(f.factor, 0)/leadingCoefficient
f.factor
>                 if Av ~= 0 then
>                   res5 := factor(univariate(eval(p3,'A::Symbol,Av)))$GF
>                   for g in factors res5 repeat
>                     if degree g.factor = 1 then
>                       a1v := -coefficient(g.factor, 0)
>                               /leadingCoefficient g.factor 
> 
>                       res := cons([rat2expr2(xx, ri.function, Av, a1v)
>                                    *(coerce(Av-(len+3)*a1v)
>                                      +coerce(a1v)*(xx::EXPRR))
>                                     **(xx::EXPRR), 
>                                    reduce(max, ri.unattainable, 0)
>                                      $List(Integer)::NNI], 
>                                   res)
>                  else
>                     a1v := kernel(opalg, [poly2expr(xx, g.factor),
xx::EXPRR])
>                     output(a1v::OutputForm)$OutputPackage
>               else
>                 a1v := kernel(opalg, [poly2expr(xx, f.factor), xx::EXPRR])
>                 output(a1v::OutputForm)$OutputPackage
> 
> If you are not careful, the 2 spaces of indentation are 
> easily overlooked...
> Of course, your analysis is correct. My point is only, that 
> with braces or parenthesis or whatever, this mistake wouldn't
> happen, not to me at least, since it was clear to me where the
> else branch should belong, but I simply missed the indentation.
> (I think, one if branch was added later, so I had to reindent
> the whole thing)
> 
> But certainly, this is highly subjective, and therefore it is 
> a real good thing that you can choose piles or no piles.
> 
> Martin
> 





reply via email to

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