For long time were mishandling nested function.  The patch
below modifies the compiler to signal error when nested
functions are encountered.  With the patch the compiler
discovered a few cases where we used nested functions.
Generated Lisp code looks bogus (AXIOMsys should crash when
executing it).  Strange thing is that ATM I am not able to
produce a testcase: the code seem to work as expected.
I really do not know _how_ current code works: attempts
to trace current code either gave no effect or infinite
recursion.  OTOH the code below gives expected trace.

For testing I used the following example:

Tr := Tree(Integer)
mytree := tree(1, [tree(2, [])$Tr, tree(3, [])$Tr])$Tr
member?(1, mytree)
member?(3, mytree)
member?(4, mytree)



The patch (including removing nested functions from algebra)
is below:

Index: src/algebra/aggcat.spad.pamphlet
===================================================================
--- src/algebra/aggcat.spad.pamphlet    (revision 548)
+++ src/algebra/aggcat.spad.pamphlet    (working copy)
@@ -526,13 +526,13 @@
      --  x
 
      s = t ==
-       eq?(s,t) => true
-       #s ~= #t => false
--- I'd rather write
---       every?(member?(#1, t), parts s)
--- but the compiler complains
-       every?(mem?, parts s) where
-           mem?(x: S): Boolean == member?(x, t)
+         eq?(s,t) => true
+         #s ~= #t => false
+         --- I'd rather write
+         ---       every?(member?(#1, t), parts s)
+         --- but the compiler complains
+         mem? : S->Boolean := member?(#1, t)
+         every?(mem?, parts s)
 
      remove_!(f:S->Boolean, t:%) ==
        for m in parts t repeat if f m then remove_!(m, t)
@@ -693,13 +693,7 @@
    cardinality s   == #s
    construct l     == (s := set(); for x in l repeat insert_!(x,s); s)
    count(x:S, s:%) == (member?(x, s) => 1; 0)
--- I'd rather write
---   subset?(s, t)   == #s < #t and every?(x +-> member?(x, t), parts s)
--- but the compiler complains
-   subset?(s, t)   ==
-       #s >= #t => false
-       every?(mem?, parts s) where
-           mem?(x: S): Boolean == member?(x, t)
+   subset?(s, t)   == #s <= #t and s = intersect(s,t)
 
 
    coerce(s:%):OutputForm ==
Index: src/algebra/tree.spad.pamphlet
===================================================================
--- src/algebra/tree.spad.pamphlet      (revision 548)
+++ src/algebra/tree.spad.pamphlet      (working copy)
@@ -117,8 +117,9 @@
     node?(t1, t2) ==
       t1 = t2 => true
       t case empty => false
-      any?(inode?, children t2) where
-         inode?(t: %): Boolean == node?(t1, t)
+      inode?:% -> Boolean := node?(t1, #1)
+      any?(inode?, children t2)
+
     leaf? t ==
       t case empty => false
       empty? children t
@@ -146,8 +147,9 @@
       true
     member?(n, t) ==
       t case empty => false
-      n = value t or any?(mem?, children t) where
-          mem?(c: %): Boolean == member?(n, c)
+      mem?: % -> Boolean := member?(n, #1)
+      n = value t or any?(mem?, children t)
+
     members t == parts t
     parts t == --buggy?
       t case empty => empty()
Index: src/interp/define.boot
===================================================================
--- src/interp/define.boot      (revision 548)
+++ src/interp/define.boot      (working copy)
@@ -47,6 +47,8 @@
     (sig:= getSignatureFromMode(lhs,e)) =>
   -- here signature of lhs is determined by a previous declaration
       compDefine1(['DEF,lhs,[first sig,:rest signature],specialCases,rhs],m,e)
+  $insideCapsuleFunctionIfTrue =>
+      stackAndThrow ['"Nested functions unsupported:", form]
   if signature.target=$Category then $insideCategoryIfTrue:= true
 --?? following 3 lines seem bogus, BMT 6/23/93
 --?  if signature.target is ['Mapping,:map] then
-- 
                              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