Bill Page wrote:
> Here is a simple patch to 'interp/i-coerce.boot' that seems to provide
> automatic coercion of all domains and categories into InputForm in the
> interpreter. According to documentation in 'i-coerce.boot' it is also
> possible to call this from algebra code but I haven't tried that yet.
> The patch is based on a lot of study of how something similar was done
> for coercions of domains and categories to OutputForm.
> 

Below is a variant of this patch.  The new functions typeToInputForm
and typeToOutputForm are inteded to be called both form algebra
and from intepreter -- they are needed for types having non-type
parameters, like the CliffordAlgebra example.  AFAICS chage to to the
OutputForm handling solves issue 16.

diff -u dist-358.bb/src/interp/i-coerce.boot dist-358/src/interp/i-coerce.boot
--- dist-358.bb/src/interp/i-coerce.boot        2008-09-07 19:05:39.000000000 
+0200
+++ dist-358/src/interp/i-coerce.boot   2008-09-24 05:24:18.631490336 +0200
@@ -765,6 +765,23 @@
 
 --% Interpreter Coercion Functions
 
+typeToInputForm(t) == typeToForm(t, '(InputForm))
+
+typeToOutputForm(t) == typeToForm(t, $OutputForm)
+
+typeToForm(t, toForm) ==
+    t0 := devaluate(t)
+    [op,:argl] := t0
+    coSig := rest GETDATABASE(op, 'COSIG)
+    sig := getConstructorSignature t0
+    ml := replaceSharps(rest sig, t0)
+    nl := [fn(x, t1, c, toForm) for x in argl for t1 in ml_
+                                for c in coSig] where
+        fn(x, t1, c, toForm) ==
+            c => typeToForm(x, toForm)
+            algCoerceInteractive(x, t1, toForm)
+    [op, :nl]
+
 coerceInteractive(triple,t2) ==
   -- bind flag for recording/reporting instantiations
   -- (see recordInstantiation)
@@ -776,7 +793,8 @@
   if t2 is ['SubDomain,x,.] then t2:= x
   -- JHD added category Aug 1996 for BasicMath
   t1 in '((Category) (Mode) (Domain) (SubDomain (Domain))) =>
-    t2 = $OutputForm => objNew(val,t2)
+    t2 = $OutputForm => objNewWrap(typeToOutputForm(val), t2)
+    t2 = '(InputForm) => objNewWrap(typeToInputForm(val), t2)
     NIL
   t1 = '$NoValueMode =>
     if $compilingMap then clearDependentMaps($mapName,nil)
  

-- 
                              Waldek Hebisch
[EMAIL PROTECTED] 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to