Waldek Hebisch <[EMAIL PROTECTED]> writes:

> Martin Rubey wrote:
> > Oh, I see now.  The right design is to simply change
> > 
> > MakeFunction(S: ConvertibleTo InputForm): Exports == Implementation where
> > 
> > to
> > 
> > MakeFunction(S: InputForm): Exports == Implementation where
> > 
> > right?
> > 
> 
> InputForm is a domain, so this will work differently than you
> expect...  Since InputForm is just a _single_ value you can
> either export function you want from MakeFunction(S: ConvertibleTo InputForm)
> or define a zero-argument package (say MakeFunction2) or (as
> Ralf suggested) directly use functions from InputForm.

Oops, I'm very sorry.  Too tired.

However, I meanwhile have what I believe is a sensible patch for some related
stuff.  I modify packageCall (currently unused), to take as second argument a
list of InputForm's, corresponding to the arguments of the function.

As an example I use it in Segment, UniversalSegment, SegmentBinding.

If this is accepted, I would next change any occurrences, where segments are
used and the call is handmade, and any occurrences where calls are handmade.

This is how such an InputForm looks like then

(1) -> (BY(sin x..,2)) :: INFORM

   (1)
   (($elt (UniversalSegment (Expression (Integer))) BY)
    (($elt (UniversalSegment (Expression (Integer))) SEGMENT) (sin x))  2)
                                                              Type: InputForm

I'm currently testing.

Martin

Index: mkfunc.spad.pamphlet
===================================================================
--- mkfunc.spad.pamphlet        (revision 416)
+++ mkfunc.spad.pamphlet        (working copy)
@@ -207,8 +207,8 @@
 ++ Description: Tools for manipulating input forms.
 
 InputFormFunctions1(R:Type):with
-  packageCall : Symbol -> InputForm
-    ++ packageCall(f) returns the input form corresponding to f$R.
+  packageCall : (Symbol, List InputForm) -> InputForm
+    ++ packageCall(f, l) returns the input form corresponding to f(l)$R.
   coerceToType : InputForm -> InputForm
     ++ coerceToType(f) returns the input form corresponding to f::R
   atType: InputForm -> InputForm
@@ -226,9 +226,11 @@
 
   getType() == Rname
 
-  packageCall name ==
-    convert([convert("$elt"::Symbol), Rname,
-                                convert name]$List(InputForm))@InputForm
+  packageCall(name, args) ==
+    convert cons(convert([convert("$elt"::Symbol), Rname,
+                          convert name]$List(InputForm))@InputForm,
+                 args)
+     
 
   coerceToType form == convert([convert("::"::Symbol), form,
                      Rname]$List(InputForm))@InputForm
Index: seg.spad.pamphlet
===================================================================
--- seg.spad.pamphlet   (revision 416)
+++ seg.spad.pamphlet   (working copy)
@@ -53,6 +53,8 @@
     convert: S -> %
         ++ convert(i) creates the segment \spad{i..i}.
 
+    if S has ConvertibleTo InputForm then ConvertibleTo InputForm
+
 @
 \section{category SEGXCAT SegmentExpansionCategory}
 <<category SEGXCAT SegmentExpansionCategory>>=
@@ -128,8 +130,21 @@
         s.incr = 1 => seg
         infix(" by "::OutputForm, seg, s.incr::OutputForm)
 
-    convert a == [a,a,1]
+    convert(a: S): % == [a,a,1]
 
+    if S has ConvertibleTo InputForm then
+        INFORM1 ==> InputFormFunctions1(%)
+
+        convert(s: %): InputForm == 
+            
+            seg := packageCall("SEGMENT"::Symbol,
+                               [convert(low s)@InputForm, 
+                                convert(hi s)@InputForm])$INFORM1
+            if one?(incr s) 
+            then seg
+            else packageCall("BY"::Symbol, 
+                             [seg, convert(incr s)@InputForm])$INFORM1
+
     if S has OrderedRing then
       expand(ls: List %):List S ==
         lr := nil()$List(S)
@@ -246,6 +261,7 @@
       ++ \spad{v=a..b}, then \spad{segment(segb)} returns \spad{a..b}.
 
   if S has SetCategory then SetCategory
+  if S has ConvertibleTo InputForm then ConvertibleTo InputForm
  == add
   Rep := Record(var:Symbol, seg:Segment S)
   equation(x,s) == [x, s]
@@ -259,6 +275,13 @@
      coerce(b:%):OutputForm ==
        variable(b)::OutputForm = segment(b)::OutputForm
 
+  if S has ConvertibleTo InputForm then
+     INFORM1 ==> InputFormFunctions1(%)
+     convert b ==
+       packageCall("equation"::Symbol, 
+                   [convert(variable(b))@InputForm, 
+                    convert(segment(b))@InputForm])$INFORM1
+
 @
 \section{package SEGBIND2 SegmentBindingFunctions2}
 <<package SEGBIND2 SegmentBindingFunctions2>>=
@@ -387,6 +410,23 @@
          inc = 1 => seg
          infix(" by "::OutputForm, seg, inc::OutputForm)
 
+    if S has ConvertibleTo InputForm then
+        INFORM1 ==> InputFormFunctions1(%)
+
+        convert(s: %): InputForm == 
+            if hasHi s then
+                seg := packageCall("SEGMENT"::Symbol,
+                                   [convert(low s)@InputForm, 
+                                    convert(hi s)@InputForm])$INFORM1
+            else
+                seg := packageCall("SEGMENT"::Symbol,
+                                   [convert(low s)@InputForm])$INFORM1
+            if one?(incr s) 
+            then seg
+            else packageCall("BY"::Symbol, 
+                             [seg, convert(incr s)@InputForm])$INFORM1
+
+
     if S has OrderedRing then
       expand(s:%)       == expand([s])
       map(f:S->S, s:%)  == map(f, expand s)


--~--~---------~--~----~------------~-------~--~----~
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 fricas-devel@googlegroups.com
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