OutputForm was designed so that operators are Symbol-s and
dealing with operators should use opearations from Symbol.
fmt.spad essentially treated operators as strings (they were
immediately converted to strings and resto of code used
string operations).  The attached patch replaces strings
by symbols, alt least in places that I found.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/ZkDL0Mt9aAzI5Myl%40fricas.org.
diff --git a/src/algebra/fmt.spad b/src/algebra/fmt.spad
index 25db609f..937cc88f 100644
--- a/src/algebra/fmt.spad
+++ b/src/algebra/fmt.spad
@@ -325,7 +325,7 @@ OutputBox : Exports == Implementation where
 ++ the name of that operator.
 OperatorHandlers(HANDLER: Type): Exports == Implementation where
   Z ==> Integer
-  S ==> String
+  S ==> Symbol
   Exports == with
     new: () -> %
       ++ \spad{new()} creates an empty structure of handlers.
@@ -419,6 +419,7 @@ FormatterCategory: Category == Exports where
   Z   ==> Integer
   N   ==> NonNegativeInteger
   S   ==> String
+  Sy  ==> Symbol
   LE  ==> List E
   BOX ==> OutputBox
   LBOX ==> S -> BOX -- Label box for prologue and epilogue
@@ -1330,8 +1331,8 @@ of a \spad{ROW} operator without the wrapping \spad{MATRIX} operator.
         opex: E := operator a2
         not symbol? opex => -1 -- error "second argument no symbol"
 
-        o2 := string symbol opex
-        o2 ~= "PAREN" => -1 -- error "second argument no PAREN"
+        o2 := symbol(opex)
+        o2 ~= 'PAREN => -1 -- error "second argument no PAREN"
 
         #(aa2 := arguments a2) > 1 => -1 -- error "second argument too long"
 
@@ -1375,8 +1376,8 @@ of a \spad{ROW} operator without the wrapping \spad{MATRIX} operator.
     formatInteger(n: Z): BOX == box convert n
     formatFloat(s: String): BOX == box s
     formatString(s: S): BOX == box s
-    formatSymbol(s: S): BOX == box s
-    formatFunctionSymbol(s: S): BOX == box s
+    formatSymbol(s : S): BOX == box(s)
+    formatFunctionSymbol(s: S): BOX == box(s)
     formatFunction(b: BOX, args: LE): BOX ==
         m: Z := minPrecedence()
         a: BOX := nary(", ", maxPrecedence(), formatExpression m)(m, args)
@@ -1398,10 +1399,10 @@ of a \spad{ROW} operator without the wrapping \spad{MATRIX} operator.
             not symbol? expr => box "[[BAD OUTPUTFORM]]"
             -- We've got a symbol here.
             -- We are in the nullary case.
-            str: S := string symbol expr
-            knownHandler?(operatorData, 0, str) =>
-                handler(operatorData, 0, str)(prec, empty()$LE)
-            formatSymbol str
+            sy : Sy := symbol expr
+            knownHandler?(operatorData, 0, sy) =>
+                handler(operatorData, 0, sy)(prec, empty()$LE)
+            formatSymbol(string(sy))
 
         -- now we take apart a list
         opex: E := operator expr
@@ -1410,7 +1411,7 @@ of a \spad{ROW} operator without the wrapping \spad{MATRIX} operator.
             formatFunction(formatExpression(opex, minPrecedence()), args)
 
         nargs: Z := #args
-        op: S := string symbol opex
+        op : Sy := symbol(opex)
 
         knownHandler?(operatorData, nargs, op) =>
             handler(operatorData, nargs, op)(prec, args)
@@ -1421,7 +1422,7 @@ of a \spad{ROW} operator without the wrapping \spad{MATRIX} operator.
 
         -- We format as a function with function name op and argument
         -- give by args.
-        formatFunction(formatFunctionSymbol op, args)
+        formatFunction(formatFunctionSymbol(string(op)), args)
 
     formatExpression(expr: E): BOX == formatExpression(expr, minPrecedence())
 
diff --git a/src/algebra/fmt1d.spad b/src/algebra/fmt1d.spad
index d0a1c17d..140e730a 100644
--- a/src/algebra/fmt1d.spad
+++ b/src/algebra/fmt1d.spad
@@ -371,7 +371,7 @@ data structure.
         PAREN p ==> bracket("(", ")", FE p)
         PAREN2(p1, p2) ==> bracket("(", ")", infix(", ", MAX, FE MIN, FE MIN))
 
-        o(n, op, hdl) ==> setHandler!(oh, n, op, hdl)
+        o(n, op, hdl) ==> setHandler!(oh, n, op::Symbol, hdl)
 
         o(0, "NOTHING",     nothing())
         o(0, "%pi",         formatConstant "%pi")
diff --git a/src/algebra/fmt2d.spad b/src/algebra/fmt2d.spad
index 72102380..2f4ac719 100644
--- a/src/algebra/fmt2d.spad
+++ b/src/algebra/fmt2d.spad
@@ -453,7 +453,7 @@ data structure.
         PAREN p ==> bracket("(", ")", FE p)
         PAREN2(p1, p2) ==> bracket("(", ")", infix(", ", MAX, FE MIN, FE MIN))
 
-        o(n, op, hdl) ==> setHandler!(oh, n, op, hdl)
+        o(n, op, hdl) ==> setHandler!(oh, n, op::Symbol, hdl)
 
         o(0, "NOTHING",     nothing())
         o(0, "%pi",         formatConstant "%pi")
diff --git a/src/algebra/fmtlatex.spad b/src/algebra/fmtlatex.spad
index 2ff08637..5c5db388 100644
--- a/src/algebra/fmtlatex.spad
+++ b/src/algebra/fmtlatex.spad
@@ -388,7 +388,7 @@ The operators have been mainly extracted from the definitions of
         BRACE p ==> bracket("{", "}", FE p)
         BRACE2(p1, p2) ==> binary(BRACE p1, BRACE p2)
 
-        o(n, op, hdl) ==> setHandler!(oh, n, op, hdl)
+        o(n, op, hdl) ==> setHandler!(oh, n, op::Symbol, hdl)
 
         o(0, "NOTHING",     nothing())
         o(0, "%pi",         formatConstant "\pi ")
diff --git a/src/algebra/fmtmathjax.spad b/src/algebra/fmtmathjax.spad
index 0bd32f0f..3a0da944 100644
--- a/src/algebra/fmtmathjax.spad
+++ b/src/algebra/fmtmathjax.spad
@@ -430,7 +430,7 @@ data structure.
         BRACE p ==> bracket("{", "}", FE p)
         BRACE2(p1, p2) ==> binary(BRACE p1, BRACE p2)
 
-        o(n, op, hdl) ==> setHandler!(oh, n, op, hdl)
+        o(n, op, hdl) ==> setHandler!(oh, n, op::Symbol, hdl)
 
         o(0, "NOTHING",     nothing())
         o(0, "%pi",         formatConstant "\pi ")

Reply via email to