[Top][All Lists]

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

Re: [Axiom-developer] Debugging Boot

From: Vanuxem Gregory
Subject: Re: [Axiom-developer] Debugging Boot
Date: Thu, 23 Nov 2006 19:27:05 +0100

Le jeudi 23 novembre 2006 à 09:14 +0100, Martin Rubey a écrit :


> I don't know how to call putWidth from within boot, i.e., after saying )fin.
> I.e., how can I access, say, an Axiom variable from boot? I'd like to say
> -------------------------------------------------------------------------------
> p := (x**2)::OUTFORM
> )fin
> putWidth(p)
> -------------------------------------------------------------------------------
> or so.

Here is a _dirty_ way to access them using the history mechanism
available in Axiom. If someone know how to access them easily (in a
different manner) I'm interested too.

First a quick overview of the the history, more precisely the
$internalHistoryTable boot variable and after a dirty way to work with
your interpreter variables.

Here I assume that you work with the history in memory (and not in a
file), which is the default. You can swith to it with:

)hist )mem

The $internalHistoryTable variable (|$internalHistoryTable| in Lisp)
contains all the history; if you want to print it issue in the
interpreter :

)boot $internalHistoryTable

All what I will say about this variable is approximate and represents
simple cases, I have to work on the history mechanism, but I'll do that
later. So please excuse and correct my errors if any.

It's a list of list (Lisp lists). Each list (entries in this mail) in
this list has the form:

((step_number "string"|(list_of_"string")
    (|variable-name| (|value| (Type) WRAPPED data))(+) 


step_numer is an integer, the number displayed in
           the interpreter in front of the command and 
           the result

        is the Axiom command and if it is a list
        contains all the previous system command
        (')something foo') and commentaries ('--something') 
        before it

(|variable-name| (|value| (Type) WRAPPED data))(+) is what
        you want, 'variable-name' is an interpreter variable
        name enclosed in vertical bars, '|value|' is |value|
        (can probably be different so beware). The rest is known,
        I presume, the value ('data'), its type 'Type' and
        WRAPPED. (+) means one or more times.

I hope you understand. Printing the $internalHistoryTable boot variable
will be more clear I think.

In the last item, if |variable-name| is % (not enclosed) this is the
output of your Axiom command (at step 'step_numer' of course). The list
of list is in reverse order. Now you have to know that there is an undo
mecanism in Axiom (costly in term of ressource) so at each Axiom command
all your variables are added to the entry added to the history so the (|
varia...) is repeated for each variables defined. So if you undo 5
commands, for example, with ')undo' Axiom will know their previous

Ok, that's all :-)

So now with that you can "extract" what you want from this variable. For
example, in debugging context, if you DON'T define variables (the simple
case, the last item is not reapeated and it's % instead of |something|)
you can access the output value of the Axiom command at step n with :

(cdadr (third (nth (- n 1)  (reverse |$internalHistoryTable|))))

A simple defun (unwrapped output):

(defun uval (step) 
  (|objValUnwrap| (cdadr 
    (third (nth (- step 1)  (reverse |$internalHistoryTable|)))))))

And if you really want to define and access variables (quickly hacked,
quickly tested):

(defun var (a step)
  (|objValUnwrap| (cdadr 
    (find-if #'(lambda (b) (and (listp b) (eq (car b) a))) 
       (nth (- step 1)  (reverse |$internalHistoryTable|))))))

To access interpreter variable 'a' at step 3 : 

(var '|a| 3)

Hope that helps,


PS : The interpreter store its variables somewhere but I don't know
where. If for example the history is kept in a file, accessing variables
(without undo) does not the involve the history file.

reply via email to

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