> Having looked at this code in more detail I find I have doubts about
> Gaby's claim: "those domains can be profitably rewritten without
> having to know how FreeModule is implemented". It seems likely to me
> that any attempt to do so could result in a significant loss of
> performance in a very critical and central part of the panAxiom
> library.

If performance suffers then the compiler must improve. I don't see a 
reason why the compiler couldn't optimize away needless function wrappers.

> Of course we can retain the current notation in panAxiom that allows
> Rep to be explicitly specified, separate from 'add', but if we want a
> less idiosyncratic approach were Rep is tied to add-inheritance it
> seems to me we need to seriously consider the option I mentioned
> earlier of making the (default?) Rep X in
> 
>    A: C2 == add
>      Rep == X
> 
> equal to the Rep of C2 and not C2 itself. I think that before choosing
> either option for the treatment of add-inheritance and Rep, it would
> be a worthwhile project to attempt to convert the above add-chain to
> the 'Rep==C2' style of representation and to evaluate the impact that
> that might have on performance.

Bill, you think too much in terms of having all the sources available. 
But imagine that you had no chance in looking inside the domain you 
inherit from. You are definitely not told about the internal representation.

If you just get Rep(X) as you proposed, then what type would that have, 
i.e. what functions can you apply to elements of Rep(X)? Where would you 
look for them? Note that X hides its implementation details. If one 
really exports Rep(X) that is against the information hiding principle 
and you need lots of programmer's discipline to produce code that does 
what it should do.

I am sure, you already know the implementation of PrimitiveArray in 
LibAldor.

http://svn.origo.ethz.ch/wsvn/algebraist/trunk/aldor/lib/aldor/src/datastruc/sal_parray.as

PrimitiveArray(T:Type): PrimitiveArrayType T == add {
     import from Machine;
#if DEBUG
     Rep == Record(sz:Z, data:Arr);
     local size(x:%):Z   == { import from Rep; { empty? x => 0; rep(x).sz }}
     local arr(x:Arr, n:Z):% == { import from Rep; { zero? n => empty; 
per [n,x]}}
     local data(x:%):Arr == {
         import from Rep;
         empty? x => (nil$Pointer) pretend Arr;
         rep(x).data;
     }
#else
     Rep == Arr;
     local data(x:%):Arr == rep x;
     local arr(x:Arr, n:Z):% == per x;
     local arr(x:Arr):%  == per x;
#endif
     ...
}

Now suppose you want to implement a SortedPrimitiveArray (in a file 
sortarr.as) like

SortedPrimitiveArray(T: OrderedType): PrimitiveArrayType T
   == PrimitiveArray(T) add {
     Rep == X;
     ...
}

what would you write for X?
And what is the type of X?

Note that you are not allowed to look inside the source code for 
PrimitiveArray. Furthermore, SortedPrimitiveArray should produce 
non-crashing code for the compilation "aldor sortarr.as" as well as for 
the compilation "aldor -DDEBUG sortarr.as". What options for X do you 
really have under these constraints?

Ralf

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to