axiom-math
[Top][All Lists]
Advanced

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

Re: [Axiom-math] some questions from a newbie


From: Martin Rubey
Subject: Re: [Axiom-math] some questions from a newbie
Date: Wed, 22 Dec 2004 09:00:30 +0100

Dear Bjarke,

> I'm running the CVS version from Savannah because the binary distributions
> did not work for me. I have a few questions listed below. Thanks to anyone
> who answers one of them.
 
> 1. Is there some way to make a function that is parametric like a package in
>    a .input file?

I'm afraid, no.
 
> 2. The "delete" button does not work. Instead of deleting the character to
>    the right of the current position, it inserts the text "^[[3~". How do I
>    fix this?

This is a problem with clef. I use emacs and shell mode, which is a lot more
comfortable than clef. An alternative is to use TeXmacs, but I won't use it, so
I can't help you there.

> 3. When the compiler finds a compile-time error in my program, most of the
>    time it reports this by basically dumping debug information about the
>    internal state of the parser (like the program as a tree in Lisp syntax
>    and the parser variables x, m and f). It does not seem to say which line
>    the error is on. Is there some way to make the compiler output more user
>    friendly error messages?

I don't think so -- at least not easily --, but it is possible to learn to
interpret them. I can offer help if you send me source and error message. As
many know, I propose to switch to the alternative compiler Aldor, which could
be used from within Axiom in past days. The syntax and semantics are very
similar, in fact, nearly identical, but I think that the compiler itself is
more mature.

> 4. Most times when Axiom displays an error, it says
>      protected-symbol-warn called with (NIL)
>    at the end. What does this mean?

This just means, that you hit an error. I don't know where it stems from. Tim
Daly might know.
 
> 5. I once got an error message that said
> 
>      >> Error detected within library code:
>      catdef: division by zero
> 
>    Is there some way to get a dump of the call-stack along with this?
>    Otherwise it is a bit hard to know where things went wrong...

You can say

)set message bottom on

or, more briefly,

)set me bo on

then Axiom (might) tell you which function is concerned. There is quite a bit
to know about debugging, I collected some bits and pieces on Mathaction:

http://page.axiom-developer.org/zope/mathaction/DebuggingAxiom

but clearly, there is a lot more to be found out.

> 6. Why does this work fine
> 
>      g(x : Integer) : Integer ==
>        d := [i for i in [1,5,3]]
>        x*x+1
> 
>    when the following results in the
>    error "NoValueMode is an unknown mode"?
> 
>      )abbrev package MYPACK MyPackage
>      MyPackage : T == C where
>       T== with
>         g: Integer -> Integer
> 
>       C== add
>         g(x : Integer) : Integer ==
>           d := [i for i in [1,5,3]]
>           x*x+1

Here we go: Axiom says

****** comp fails at level 4 with expression: ******
error in function g 

(SEQ (LET |d|
       (COLLECT (IN |i| | << | (|construct| 1 5 3) | >> |) |i|))
     (|exit| 1 (+ (* |x| |x|) 1)))
****** level 4  ******
$x:= (construct (One) 5 3)
$m:= $EmptyMode
$f:=
((((|x| # #) (* # # #) (** # # #) (+ # #) ...)))
 
   >> Apparent user error:
   NoValueMode
    is an unknown mode

Axiom says that it hasn't found a mode (= roughly type) for x, where 
x =  [1, 5, 3].

So, let's help Axiom a bit:

         g(x : Integer) : Integer ==
           d := [i for i in [1,5,3]$(List Integer)]
           x*x+1

should work. NOTE: The compiler is bugged, the interpreter is bugged and the
compiler-interpreter interaction is bugged. Hence: 

* don't trust the error messages too much, take them as hints. After a while
  you'll get a feeling what you really need to declare. (Since I think I've got
  this feeling already, I offer you help)

* you might like to consider the transcript of the axiom session where I fixed
  your package definition. After I changed the definition of g and recompiled,
  the compiler didn't complain anymore, but the results were, at the least
  surprising. Restarting Axiom made the problem go away. I added it at the
  bottom.

> 7. Axiom will accept the input
> 
> )abbrev package MYPACK MyPackage
> MyPackage : T == C where
>  T== with
>    myFun: Integer -> Integer
>    myFun2: Integer -> Integer
> 
>  C== add
>    myFun(x : Integer) : Integer == x*x + 1
> 
> just fine. If I try to call myFun2, it says
> 
> Internal Error
>    The function myFun2 with signature hashcode is missing from domain
>       MyPackage
> 
> How do I get Axiom to refuse to accept packages whose signature does not
> match their implementation?

I don't know. Consider, however, that for categories, it is a necessary feature
to be able to declare operations which are not defined.
> 
> 8. How do I get Axiom to quit bugging me about not having documented
>    functions in .spad files?

That's a feature! :-) Ask Tim.
> 
> 9. How do I make the Axiom compiler less verbose? I only want error
>    messages and warnings.

The autoload messages (which make a lot of noise) can be switched off by saying

)set me autoload off

I didn't care for compiler noise, so I don't know about that one. You might
however like to open a second axiom session for compiling, and, after a
successful compile, say

)lib MYPACK

in the other.
 
Hope this helps. I'm very happy that another one tries to use the axiom
compiler! Maybe you'd even like to hack axiom to use the Aldor compiler again?
So far it is possible to use it for simple function definitions, but domains
compiled by Aldor cannot be used within Axiom anymore, sadly.

Martin

                        AXIOM Computer Algebra System 
                Version of Sunday April 18, 2004 at 14:52:45 
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------
 
   Re-reading compress.daase   Re-reading interp.daase
   Re-reading operation.daase
   Re-reading category.daase
   Re-reading browse.daase
(1) -> )set me autoload off
(1) -> g(x : Integer) : Integer == d := [i for i in [1,5,3]] x*x+1
   Function declaration g : Integer -> Integer has been added to 
      workspace.
                                                                   Type: Void
(2) -> )co test.spad 
   Compiling AXIOM source code from file /home/martin/test.spad using 
      old system compiler.
   MYPACK abbreviates package MyPackage 
------------------------------------------------------------------------
   initializing NRLIB MYPACK for MyPackage 
   compiling into NRLIB MYPACK 
   compiling exported g : Integer -> Integer
Time: 0.06 SEC.

(time taken in buildFunctor:  0)

;;;     ***       |MyPackage| REDEFINED

;;;     ***       |MyPackage| REDEFINED
Time: 0 SEC.


   Cumulative Statistics for Constructor MyPackage
      Time: 0.06 seconds
 
   finalizing NRLIB MYPACK 
   Processing MyPackage for Browser database:
--->-->MyPackage((g ((Integer) (Integer)))): Not documented!!!!
--->-->MyPackage(constructor): Not documented!!!!
--->-->MyPackage(): Missing Description
Compiling /home/martin/./MYPACK.NRLIB/code.lsp.
; (DEFUN |MYPACK;g;2I;1| ...) is being compiled.
;; Warning: The variable $ is not used.
End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
Finished compiling /home/martin/./MYPACK.NRLIB/code.lsp.
------------------------------------------------------------------------
   MyPackage is now explicitly exposed in frame initial 
   MyPackage will be automatically loaded when needed from 
      /home/martin/MYPACK.NRLIB/code

(2) -> g(4)
   Compiling function g with type Integer -> Integer 
 
   >> Error detected within library code:
   index out of range

protected-symbol-warn called with (NIL)
(2) -> g(3)

   (2)  10
                                                        Type: PositiveInteger





reply via email to

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