[Top][All Lists]

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

[Axiom-developer] where is the symbol?

From: root
Subject: [Axiom-developer] where is the symbol?
Date: Wed, 23 Jul 2003 23:06:34 -0400

Bill, Camm,

You'd think that your question about where the symbol is interned
would be easy to answer but it is not. The top level loop uses Bill
Burge's dreaded zipper parser. You can see it in action by executing
the following sequence:

)lisp (setq $DALYMODE t)    ;;; this is a special mode of the top level
                            ;;; interpreter. If $DALYMODE is true then
                            ;;; any top-level form that begins with an
                            ;;; open-paren is considered a lisp expression.
                            ;;; For almost everything I ever do I end up
                            ;;; peeking at the lisp so this bit of magic helps.
(trace |intloopProcessString|) ;; from int-top.boot.pamphlet
(trace |intloopProcess|)       ;; the third argument is the "zippered" input
(trace |intloopSpadProcess|)   ;; now it is all clear, no? sigh.
(trace |phInterpret|)          ;; from int-top.boot.pamphlet
(trace |intInterpretPform|)    ;; from intint.lisp.pamphlet
(trace |processInteractive|)   ;; from i-toplev.boot.pamphlet
(setq $reportInstantiations t) ;; shows what domains were created
(trace |processInteractive1|)  ;; from i-toplev.boot.pamphlet

ah HA! I remember now. There is the notion of a "frame" which is
basically a namespace in Axiom or an alist in Common Lisp. It is
possible to maintain different "frames" and move among them. There
is the notion of the current frame and it contains all the defined
variables. At any given time the current frame is available as
|$InteractiveFrame|. This variable is used in |processInteractive1|.
If you do:

(pprint |$InteractiveFrame|)

you'll see |a| show up on the alist. When you do the 

pgr:=MonoidRing(Polynomial PrimeField 5, Permutation Integer)

you'll see |p| show up with 2 other things: (|p| mode value)
where mode is the "type" of the variable. The value is the
internal value. In this case MonoidRing has an internal
representation. You can find out what the internal representation
of a MonoidRing is by first asking where the source file is:

(do this at a shell prompt, not in axiom)
asq -so MonoidRing ==> mring.spad

     -- or -- in Axiom type:

)show MonoidRing

and you'll see a line that reads: 
Issue )edit (yourpath)/../../src/algebra/mring.spad

If you look in mring.spad.pamphlet you'll see line 91 that reads:

   Rep := List Term

which says that we will store elements of type MonoidRing as a list
of Term objects. Term is defined in the same file (as a macro, which
is what '==>' means in spad files) on line 43:

   Term ==> Record(coef: R, monom: M)

which means that elements of a MonoidRing are Lists of Records.
The 'R' is defined on line 42 as the first argument to MonoidRing
which in this case is 'Polynomial PrimeField 5'. The 'M' is also
defined on line 42 as the second argument to MonoidRing and in this
case is 'Permutation Integer'. So the real representation is

  List Record(coef: Polynomial PrimeField 5, monom: Permutation Integer)

In the |$InteractiveFrame| we printed out you can see in the |value|
field that the value is:

(|value| (|MonoidRing| (|Polynomial| (|PrimeField| 5)) (|Permutation| 
(|Integer|))) WRAPPED ((0 . 1) . #<vector 08af33d4>))

which basically means that we know how the MonoidRing was constructed and
what it's current value is. The (0 . 1) likely means that this is the
zeroth (constant) term with a leading coefficient of 1. This is just a
guess as I haven't decoded the representation of either Polynomial PrimeField 
or Permutation Integer. You can do the same deconstruction of these two
domains by setting

pi:=Permutation Integer

pp5:=Polynomial PrimeField 5

and following the same steps as above: 
 (pprint |$InteractiveFrame|)
 )show pi
 (find the source file)
 (find the representation and decode it)

 (pprint |$InteractiveFrame|)
 )show pp5
 (find the source file)
 (find the representation and decode it)

Be sure to set $DALYMODE to nil if you plan to use Axiom for any
real computation. Otherwise every expression that begins with an
open-paren will go directly to lisp.

Sorry I took so long but it's been a while.
Hope this helps.


reply via email to

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