Hi Waldek,

from Aldor I know the behaviour that if one overloads a function in a
domain that one inherits from, it does not change the behaviour of the
other functions.

To demonstrate it, here is a SPAD program that behaves exactly as Aldor
does.

 (1) -> a1: DomA1 := 2

   (1)  10
                                               Type: DomA1
(2) -> a2: DomA2 := 3

   (2)  15
                                               Type: DomA2

Can I rely on this behaviour of SPAD?

In particular, coming from other object oriented programming languages,
one might expect that redefinition of foo in DomA2 has influence on the
coerce that is inherited from DomA1 in DomA2 (via virtual function table).

Aldor (as per Aldor User Guide) does not change coerce and SPAD is
seemingly behaving identically, otherwise (2) would show 21 instead of 15.

Ralf

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
)nopile
rep x ==> (x@%) pretend Rep
per x ==> (x@Rep) pretend %

)abbrev category XCAT Cat
Cat: Category == with {
  coerce: Integer -> %;
  coerce: % -> OutputForm;
  foo: % -> Integer
}
)abbrev domain XDOMA1 DomA1
DomA1: Cat == add {
  Rep ==> Integer;
  import from Integer;
  coerce(i: Integer): % == per i;
  foo(x: %): Integer == 5 * (rep x);
  coerce(x: %): OutputForm == foo(x)::OutputForm;
}

)abbrev domain XDOMA2 DomA2
DomA2: Cat == DomA1 add {
  Rep ==> Integer;
  import from Integer;
  foo(x: %): Integer == 7 * (rep x);
}

)if INPUT
a1: DomA1 := 2
a2: DomA2 := 3
)endif

Reply via email to