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: Waldek Hebisch
Subject: Re: [Axiom-developer] No progress on notangle
Date: Mon, 19 Feb 2007 01:41:44 +0100 (CET)

> > 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.
>

Suppose that your program contains an arbitrary sequence of '@', '<<'
and '>>'.  Do you know how to write the source file to get required
output?  I did not want to waste time on this problem, but a few
trials gave rather bizzare results.

Your example suggest that notangle is consistent in its indentation
rules, but if you take "random" input the results look strange.

Also, I thought that notagle is inconsistent in it treatment of
tabs (sometimes mangles then, but preserves leading tabs in Makefiles),
but it seems that normaly notagle consistently mangles tabs and
just needs extra option to preserve tabs.

> >> 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.

ATM CL version also do not indentate.  It puts first char of the chunk
in the same line as <<xxx>> marker, but of course printing '#line' we
can also emit a newline before it.

> 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.

I am asking to understand which features of notangle are useful.  Would
you need notangle for a programming language where by default input is
a comment, all code must be in procedures/functions, you can write
procedures in arbitrary order and you can have arbitrary procedure names
(but with special begin/end name markers).
In such language your example could look like:

<<implementation: 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$>>(f, g, h)
      }
      <<build up the Gosper triple $(p, q, c)$>>
      (p, q, c)
@

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

That would be less flexible that notangle because of need for explicit
parameter passing, but at least for me having explicit parameters 
(and explicit scopes) makes text more readable.

-- 
                              Waldek Hebisch
address@hidden 




reply via email to

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