On 04/07/2008 01:55 PM, Martin Rubey wrote:
> Ralf Hemmecke <[EMAIL PROTECTED]> writes:
> 
>>> | Note that at first I thought that introducing Aldor's extend would 
>>> invalidate
>>> | my reasoning.  But it turns out, that at least the current Aldor compiler 
>>> does
>>> | *not* allow overriding domain definitions either.  I could not find 
>>> anything
>>> | appropriate in the Aldor User Guide though.
>> Martin, what exactly do/did you mean by that?
> 
>     [EMAIL PROTECTED]:~/aldor-test$ aldor -fx -laldor override.as
>     [EMAIL PROTECTED]:~/aldor-test$ ./override
>     foo()$Bar: foo$Bar
>     bar()$Bar: foo$Bar + bar$Bar
>     foo()$Foo: foo$Foo
>     bar()$Foo: foo$Bar + bar$Bar
> 
> Thus, bar$Foo calls foo()$Bar.  The call to foo in Bar was *not* replaced by
> foo()$Foo.

Yes, that seems to be strange, but that is how Aldor is designed.
If you call bar$Foo then you take the implementation of bar in Bar since 
that is what "Bar add {...}" for Foo says.

Well, bar$Bar behaves like bar$Bar.

Don't worry, there were times when I stepped into the same trap. ;-)

As for extend ... (as I understand it)

extend Foo: A == add {...}

is basically the same as

Foo': Join(Category-Of-Foo, A) == Foo add {...}

and then renaming Foo' to Foo (and thus hiding Foo). So one shouldn't 
expect something different from the non-extend version.

Ralf

> #include "aldor"
> #include "aldorio"
> 
> Bar: with {
>       foo: () -> String;
>       bar: () -> String;
> } == add {
>       foo(): String == "foo$Bar";
>       bar(): String == foo() + " + bar$Bar";
> }
> 
> Foo: with {
>       foo: () -> String;
>       bar: () -> String;
> } == Bar add {
>       foo(): String == "foo$Foo";
> }
> 
> #if WithExtend
> extend Foo: with {
> } == add {
>       foo(): String == "foo$Ext";
> }
> #endif
> 
> stdout << "foo()$Bar: " << foo()$Bar << newline;
> stdout << "bar()$Bar: " << bar()$Bar << newline;
> stdout << "foo()$Foo: " << foo()$Foo << newline;
> stdout << "bar()$Foo: " << bar()$Foo << newline;

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to