axiom-developer
[Top][All Lists]
Advanced

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

Re: [Axiom-developer] No progress on notangle


From: Ralf Hemmecke
Subject: Re: [Axiom-developer] No progress on notangle
Date: Sun, 18 Feb 2007 23:37:19 +0100
User-agent: Thunderbird 2.0b2 (X11/20070116)

First I have noticed that notangle behaves in rather inconsitent
way.

Really? I've met some cases where notangle does not as I would like, but these cases are rare.

I do not want to waste time trying to find out exact rules used
by notangle.  With pile semantics it seems better to integrate
notangle like processing with Spad scanning and treat each hunk as
a pile (IMHO having piles spanning hunk boundary is just confusing
and error prone).

Of course, I would also forbid the equivalent way of saying

<<*>>=
foo(): () == {
   some code
@
some doc
<<*>>=
   some more code
}
@

But the code I gave was not of that style.

Furthermore what about the option "-L" that can be given to notangle?
That is particularly useful if your compiler emits a column number for error messages. #pile mode is bad in that case anyway, but there are also files that are indentation-independent.

That could be easily addedd: the program traces line numbers anyway
(for debugging purposes) so it would be easy to store them together
with chunks and emit when needed.

But you know that then notangle doesn't indentate? If you remove the #line lines from the output of "notangle -L ..." you don't get the same output as "notangle ...". And this is actually a good thing. I once complaint about the missing indentation, but Norman refused to change the behaviour and he is right.

---BEGIN aaa.spad.pamphlet
<<*>>=
foo(x: Integer): Integer == <<foo body>>
@

<<foo body>>=
z := 1
for i in 1.. x repeat
     <<auxiliary computation>>
     h := <<post computation>>
     <<binding z>>
z
@

<<auxiliary computation>>=
h := 1
for j in 1..i repeat
     h := h + j
     h := 2*h
@

<<post computation>>=
if h > 100
   then
     h-2
   else
     h+2
@

<<binding z>>=
h := 3*h
z := h
@
---END aaa.spad.pamphlet

BTW:  is the the test program supposed to be in good literate style?
both <<auxiliary computation>> and <<binding z>> change h without
any hint about such possibility in <<foo body>>.  I find such
practice _very_ bad for readability.

Of course that was just a cooked up example for the indentation problem. What I like is code like...

<<implementation: gosperForm>>=
gosperForm(f: P, g: P): (P, P, P) == {
    import from FractionalRoot Integer;
    import from Integer;
    nonNegativeIntegerRoots: Generator Integer := {
        <<nonnegative integers $h$ with $\gcd(f(n),g(n+h))\ne1$>>
    }
    <<build up the Gosper triple $(p, q, c)$>>
    (p, q, c)
}
@

<<non-negative integers $h$ with $\gcd(f(n),g(n+h))\ne1$>>=
r: UPh := resultant(lift(f), lift(g)(n+h::UPhn));
v for i in integerRoots r | (v:=integralValue i) > 0;
@

<<build up the Gosper triple $(p, q, c)$>>=
c:P := 1;
p := f;
q := g;
for root in nonNegativeIntegerRoots repeat {
        u:P := gcd(p, q(x + root::P));
        p := quotient(p, u);
        q := quotient(q, u(x - root::P));
        for j in 1..root repeat c := c*u(x - j::P);
}
@

... and even that could be improved. (I omitted the latex part.)

Anyway, I don't claim that I know the best way to write literate programs.

Ralf




reply via email to

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