--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Wed Sep 14 11:40:47 1994
--* Received: from yktvmv-ob.watson.ibm.com by asharp.watson.ibm.com (AIX 3.2/UCB 5.64/930311)
--*           id AA32600; Wed, 14 Sep 1994 11:40:47 -0400
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 1989; Wed, 14 Sep 94 11:40:51 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.HEMMECKE.NOTE.YKTVMV.1151.Sep.14.11:40:49.-0400>
--*           for asbugs@watson; Wed, 14 Sep 94 11:40:51 -0400
--* Received: from server1.rz.uni-leipzig.de by watson.ibm.com (IBM VM SMTP V2R3)
--*    with TCP; Wed, 14 Sep 94 11:40:37 EDT
--* Received: from aix550.informatik.uni-leipzig.de by server1.rz.uni-leipzig.de with SMTP
--* 	(1.36.108.7/15.6) id AA07549; Wed, 14 Sep 1994 17:40:18 +0200
--* Received: by aix550.informatik.uni-leipzig.de (AIX 3.2/UCB 5.64/BelWue-1.1AIXRS)
--*           id AA48485; Wed, 14 Sep 1994 17:46:13 +0100
--* Date: Wed, 14 Sep 1994 17:46:13 +0100
--* From: hemmecke@aix550.informatik.uni-leipzig.de (Ralf Hemmecke)
--* Message-Id: <9409141646.AA48485@aix550.informatik.uni-leipzig.de>
--* To: asbugs@watson.ibm.com
--* Subject: [4] effect of overloading a function

--@ Fixed  by:  SSD   Thu Sep 15 16:36:39 EDT 1994 
--@ Tested by:  none 
--@ Summary:    Implementation inheritance works slightly differently. 

-- Command line: asharp -DC1 -G run xxx.as
-- Version: A# version 0.36.5 for AIX RS/6000
-- Original bug file name: xxx.as

-- The first 2 domains are copies from binadd.as in the directory test.
-- We added de domain XXX and the marked lines.
-- Compilation is no problem, but the result differs from what would one
-- expect.
-- Running this file via:
--	asharp -DC1 -G run xxx.as
-- gives the answer: 5, 11, 2, 7,
-- running via:
--      asharp -DC1 -G run xxx.as
-- yields: 5, 14, 2, 7.

-- It is our understanding that ifunction "a" in XXX is overloaded and
-- therefore "bar" in XXX should change accordingly.
-- Why is it necessary to copy the line
--   bar(x: %):SI == a(x) + b(x)
-- or is there anything we do not understand correctly?

#pile

#include "aslib"

SI ==> SingleInteger

Foo: with
        foo: (SI, SI) -> %
        a:   % -> SI
        b:   % -> SI
    == add
        Rep ==> Record(a: SI, b: SI)
        import from Rep
        foo(a:SI, b: SI): % == per [a,b]
        a(x: %): SI == rep(x).a
        b(x: %): SI == rep(x).b

Bar: with
        foo: (SI, SI) -> %
        bar: % -> SI
        a:   % -> SI
        b:   % -> SI
    == Foo add
        bar(x: %):SI == a(x) + b(x)

XXX: with
	foo: (SI, SI) -> %
	a:   % -> SI
	b:   % -> SI
        bar: % -> SI
    == Bar add
	a(x:%):SI == b(x)
#if C1
#elseif C2
        bar(x: %):SI == a(x) + b(x)
#endif

import from SI
local x: Bar == foo(2,3)
local y: XXX == foo(4,7) --added
print<<bar(x)<<newline
print<<bar(y)<<newline --added
print<<a(x)<<newline
print<<a(y)<<newline  --added

 
--+ The domain Bar provides operations `a', `b', and `bar',
--+ where the definition of `bar' from Bar uses `a' from Bar.
--+ `bar' is a function on elements from Bar.
--+ 
--+ The domain XXX provides the operation `a', so a call to a$XXX
--+ gets this definition.  It inherits the `bar' operation from
--+ Bar, which uses the `a' operation from Bar.  This kind of
--+ inheritance (implementation inheritance) can be thought of
--+ as "however bar$Bar works on members of Bar, it should work on
--+ members of XXX".
--+ 
--+ So the program is performing according to the specification,
--+ its just that you want a slightly different kind of inheritance.
