axiom-developer
[Top][All Lists]
Advanced

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

[Axiom-developer] Quick question on the symbol issue:


From: Camm Maguire
Subject: [Axiom-developer] Quick question on the symbol issue:
Date: 24 Sep 2004 13:11:27 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!  

OK, the issue does not appear to be with the underlying lisp as far as
I can tell.  Please correct me if I am in error (with verifiable
details if possible).  Rather the new() functions in SYMBOL.spad do
not check that the user might have referred previously to a symbol
with the 'special' % prefix.  Alternatively, perhaps it was intended
that % act somewhat like the #: lisp reader macro in designating a
symbol that is to be uninterned.  If this is the case, please point me
to the code that is intended to establish this behavior and I'll look
at it.

Assuming the rather more likely scenario that the design simply did
not intend for users to set by hand symbols beginning with % (as it
does appear to be used as some sort of escape), the following patch
will increment the counter as necessary to step over symbols already
so interned:

(sid)address@hidden:/fix/g/camm/axiom/axiom-0.20040831/src/algebra$ diff -u 
symbol.spad.pamphlet.ori symbol.spad.pamphlet
--- symbol.spad.pamphlet.ori    2004-05-24 22:53:45.000000000 +0000
+++ symbol.spad.pamphlet        2004-09-24 16:51:41.000000000 +0000
@@ -252,27 +252,32 @@
         if zero?(n) then return ns
       
     new() ==
-      sym := anyRadix(count()::Integer,ALPHAS)
-      count() := count() + 1
-      concat("%",sym)::%
+      repeat
+        sym := anyRadix(count()::Integer,ALPHAS)
+        count() := count() + 1
+        ns := concat("%",sym)
+        if not FIND_-SYMBOL(ns)$Lisp then return ns::%
 
     new x ==
-      n:Integer :=
-        (u := search(x, xcount)) case "failed" => 0
-        inc(u::Integer)
-      xcount(x) := n
-      xx := 
-        not scripted? x => string x
-        string name x
-      xx := concat("%",xx)
-      xx :=
-        (position(xx.maxIndex(xx),nums)>=minIndex(nums)) => 
-          concat(xx, anyRadix(n,alphas))
-        concat(xx, anyRadix(n,nums))
-      not scripted? x => xx::%
-      script(xx::%,scripts x)
+      repeat
+        n:Integer :=
+          (u := search(x, xcount)) case "failed" => 0
+          inc(u::Integer)
+        xcount(x) := n
+        xx := 
+          not scripted? x => string x
+          string name x
+        xx := concat("%",xx)
+        xx :=
+          (position(xx.maxIndex(xx),nums)>=minIndex(nums)) => 
+            concat(xx, anyRadix(n,alphas))
+          concat(xx, anyRadix(n,nums))
+       if not FIND_-SYMBOL(xx)$Lisp then
+          if not scripted? x then return xx::%
+          return script(xx::%,scripts x)
 
     resetNew() ==
+--    Do we want to unintern the symbols previously interned here?
       count() := 0
       for k in keys xcount repeat remove_!(k, xcount)
       void


As noted in the comment, regardless of resetNew(), subsequent
invocations of new() will start where the counter left off, unless one
adds code to unintern the specified symbols, which in this case might
wipe out a symbol explicitly specified by the user.  Don't know what
is best here, though I suspect the latter.

As for gensym, it returns a fresh *uninterned* symbol at all times.
(eq '#:g '#:g) ==> nil.  Axiom is printing the symbol without this
special syntax which might alert one to what is going on.  In short,
G1419::Symbol *is in fact distinct* from the return value of
symbol(GENSYM()$Lisp) even when the print value is the same.  The
former is interned and can be retrieved again by the same user input.
The latter is lost forever unless saved as the value of some other
variable.  You will never be able to write code trying to refer to
gensymmed output by the printed symbol name.  This is also the case in
lisp as the example above shows.  So not sure if any changes are
warranted here.

Please let me know if this is all off base.  And yes, in answer to
your previous question, though not a mathematician, I have a Ph.D. in
theoretical physics, and so could work on math bugs in axiom providing
they are not too specialized.  As time is short, I'd really prefer not
working on things which are not *important*, which I'm defining here
as increasing the utility of as many people as possible by as much as
possible. 

Take care,

> (1) -> %A::Symbol
> 
>    (1)  %A
>                                                                  Type: Symbol
> (2) -> new()$Symbol
> 
>    (2)  %A
>                                                                  Type: Symbol
> (3) -> G1419::SYMBOL
> 
> 
>    (3)  G1419
>                                                                  Type: Symbol
> (4) -> symbol(GENSYM()$Lisp)
>    Loading /home/rubey/axiom/mnt/linux/algebra/SEX.o for domain 
>       SExpression 
>    Loading /home/rubey/axiom/mnt/linux/algebra/DFLOAT.o for domain 
>       DoubleFloat 
>    Loading /home/rubey/axiom/mnt/linux/algebra/SEXOF.o for domain 
>       SExpressionOf 
> 
>    (4)  G1419
>                                                                  Type: Symbol
> 
> (5) -> b:=%B
> 
>    (5)  %B
>                                                             Type: Variable %B
> (6) -> new()$Symbol
> 
>    (6)  %B


-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

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