Martin Rubey <[EMAIL PROTECTED]> writes:

| Gabriel Dos Reis <[EMAIL PROTECTED]> writes:
| 
| > | So, my question is: how would you interpret an operation that is 
inherited from
| > | IndexedDirectProductAbelianGroup(R,S), when the representations are
| > | incompatible as they are here?
| > 
| > Of course when the data layout are not right, disaster.  But, that is beside
| > the fundamental point.  There are many domains that do not manipulate their
| > representations directly.
| > 
| > The fundamental point is that this particular semantics seriously inhibits
| > code reuse.  There is no way to extend a domain.  Spad seems to promote
| > copy-n-paste as way to add new domains.  That is contrary to established
| > software engineering practice.
| 
| Gaby, after some experiments, I could not find an example where "A add B", A
| and B sharing representation, exports an operation from A instead of from B,
| when the signature is present in both.

That is basically what my oiriginal example was about -- you just
needed to flip the component to match exact layout.  I'm reproducing
it below

)sys cat left.spad
)abbrev domain LFREEMOD LeftFreeModule
LeftFreeModule(R: Ring, S: OrderedSet):
     Join(LeftModule R, IndexedDirectProductCategory(R,S)) with
       linearCombination: List Pair(S,R) -> %
  == IndexedDirectProductAbelianGroup(R,S) add
    Rep == List Pair(S,R)
    linearCombination x ==
      per [u for u in x | second u ~= 0$R ]
    if R has EntireRing then
      (r: R) * (x: %) ==
        r = 0$R => 0$%
        r = 1$R => x
        messagePrint("from LeftFreeModule")$OutputForm
        per [pair(first u, r * second u) for u in rep x]
    else
      (r: R) * (x: %) ==
        r = 0$R => 0$%
        r = 1$R => x
        messagePrint("from LeftFreeModule")$OutputForm
        per [pair(first u,c) for u in rep x | (c := r *second u) ~= 0$R]
    coerce(x: %): OutputForm ==
      x' := rep x
      null x' => 0$R :: OutputForm
      res : List OutputForm := nil
      for u in reverse x' repeat
        second u = 1$R => res := cons(first(u)::OutputForm, res)
        res := cons(second(u)::OutputForm * first(u)::OutputForm, res)
      reduce("+",res)

)co left
x := 'x::OrderedVariableList ['x,'y]
x := 'y::OrderedVariableList ['x,'y]
2 * linearCombination([pair(x,2), pair(y,3)])


There is no 'from LeftFreeModule' printed out.

[...]

| In any case, I think that the compiler should complain when the Rep's don't
| match.

If you read the paper I referenced earlier, you'll see hat both BMT
and JHD have (had?) different opinions on this :-)

But, yes the compiler should warn about differing representations.
the problem is that in general, the cmpiler does not have that
information.  compounded by the heavy uses of `pretend'.

-- Gaby

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to