Suppose, I have a category with a default function implementation and I define another category that inherits from the first one an gives another default implementation for that function.

Can I rely on the behaviour below?

I have tried this in Aldor and seem to remember that somewhere in the Aldor description it deliberately leaves it unspecified in which order the defaults are taken. Indeed Aldor yields different results.

I guess I also shouldn't rely on the current behaviour of the SPAD compiler, right?

Ralf



(2) -> [foo(1)$Bar, bar(1)$Bar, baz(1)$Bar]

   (2)  [1, 2, 6]
                                                  Type: List(Bar)
(3) -> [foo(1)$FooBar, bar(1)$FooBar, baz(1)$FooBar]

   (3)  [1, 2, 6]
                                                Type: List(FooBar)
(4) -> [foo(1)$BarFoo, bar(1)$BarFoo, baz(1)$BarFoo]

   (4)  [1, 2, 6]
                                                Type: List(BarFoo)


%%15 >> [foo(1)$Bar, bar(1)$Bar, baz(1)$Bar]$List(Bar)
[1,2,6] @ List(Bar)
                                           Comp: 20 msec, Interp: 0 msec
%%16 >> [foo(1)$FooBar, bar(1)$FooBar, baz(1)$FooBar]$List(FooBar)
[1,1,3] @ List(FooBar)
                                           Comp: 10 msec, Interp: 10 msec
%%17 >> [foo(1)$BarFoo, bar(1)$BarFoo, baz(1)$BarFoo]$List(BarFoo)
[1,2,6] @ List(BarFoo)

--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/51c5843d-76e5-91c6-9111-1d977c7636ac%40hemmecke.org.
)abbrev category FOOCAT FooCat
FooCat: Category == CoercibleTo OutputForm with
    foo: Integer -> %
    bar: Integer -> %
  add
    bar(n: Integer): % == foo(n)

)abbrev category BARCAT BarCat
BarCat: Category == FooCat with
    baz: Integer -> %
  add
    bar(n: Integer): % == foo(2*n)
    baz(n: Integer): % == bar(3*n)

)abbrev domain BAR Bar
Bar: BarCat == Integer add
    coerce(x: %): OutputForm == (x pretend Integer)::OutputForm
    foo(n: Integer): % == n pretend %

)abbrev domain FOOBAR FooBar
FooBar: Join(FooCat, BarCat) == Integer add
    coerce(x: %): OutputForm == (x pretend Integer)::OutputForm
    foo(n: Integer): % == n pretend %

)abbrev domain BARFOO BarFoo
BarFoo: Join(BarCat, FooCat) == Integer add
    coerce(x: %): OutputForm == (x pretend Integer)::OutputForm
    foo(n: Integer): % == n pretend %

Attachment: foo.as
Description: application/applix-spreadsheet

#include "aldor"
#include "aldorio"
#library FOO "foo.ao"
import from FOO
import from Integer
[foo(1)$Bar, bar(1)$Bar, baz(1)$Bar]$List(Bar)
[foo(1)$FooBar, bar(1)$FooBar, baz(1)$FooBar]$List(FooBar)
[foo(1)$BarFoo, bar(1)$BarFoo, baz(1)$BarFoo]$List(BarFoo)

Reply via email to